0

Does anybody know why ggplot is not showing bars in my case?

ggplot:

enter image description here

If I use classic, it looks like this:

enter image description here

my code looks like this:

style.use('ggplot')

def graph(candlestick_list):

    df = pd.DataFrame(candlestick_list)
    ohlc = df[['date', 'open', 'high', 'low', 'close']]

    ax1 = plt.subplot2grid((6,1), (0,0), rowspan=5, colspan=1)
    ax2 = plt.subplot2grid((6,1), (5,0), rowspan=5, colspan=1, sharex=ax1)
    candlestick_ohlc(ax1, ohlc.values, width=0.5, colorup='g', colordown='r')
    ax2.bar(df['date'], df['volume'])

UPDATE: After restarting the computer ggplot seems to show the bar plot, but shows now gaps. This is the current ggplot: enter image description here

sunwarr10r
  • 4,420
  • 8
  • 54
  • 109
  • It looks to me that it has ticks... you just want to personalize them, maybe. Have you tried with "ax1.set_tick_params(axis='x', direction='in',which='major')" for ax1 and ax2, eventually major ticks, minor ticks, x and y? https://matplotlib.org/api/_as_gen/matplotlib.axis.Axis.set_tick_params.html#matplotlib.axis.Axis.set_tick_params – Dr.Raghnar Jul 06 '17 at 13:55
  • Just tried it and got: `AttributeError: 'AxesSubplot' object has no attribute 'set_tick_params'` – sunwarr10r Jul 06 '17 at 14:06
  • depends which class are you invoking, if you are in subplot or not. There are several ways to plays with properties and ticks in subplots. Have a look here: https://matplotlib.org/devdocs/api/_as_gen/matplotlib.axes.Axes.tick_params.html and here: https://stackoverflow.com/questions/19626530/python-xticks-in-subplots and this: https://stackoverflow.com/questions/13052844/matplotlib-how-to-decrease-density-of-tick-labels-in-subplots – Dr.Raghnar Jul 06 '17 at 15:13
  • How many bars do you have? Does the problem still occur if you use less bars? – ImportanceOfBeingErnest Jul 07 '17 at 12:23
  • If I use less bars, the problem doesn't occur. But other ones, like the bars merging with each others – sunwarr10r Jul 07 '17 at 12:53

1 Answers1

0

You can try to adjust ticks using plt.setp(axes, xticks=list(range(0, 24, 5))). You can also adjust yticks, the same way shown for "x".

Mert Karakas
  • 178
  • 1
  • 4
  • 22