【发布时间】:2017-07-06 13:40:41
【问题描述】:
有人知道为什么ggplot 在我的情况下没有显示条形吗?
ggplot:
如果我使用经典,它看起来像这样:
我的代码如下所示:
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'])
【问题讨论】:
-
在我看来,它有刻度...您可能只是想个性化它们。您是否尝试过对 ax1 和 ax2 使用“ax1.set_tick_params(axis='x', direction='in',which='major')”,最终是主要滴答声、次要滴答声、x 和 y? matplotlib.org/api/_as_gen/…
-
刚试了一下,得到:
AttributeError: 'AxesSubplot' object has no attribute 'set_tick_params' -
取决于你在调用哪个类,如果你在子情节中。有几种方法可以在子图中使用属性和刻度。看看这里:matplotlib.org/devdocs/api/_as_gen/… 和这里:stackoverflow.com/questions/19626530/python-xticks-in-subplots 和这个:stackoverflow.com/questions/13052844/…
-
你有多少个酒吧?如果使用较少的条,问题是否仍然存在?
-
如果我使用较少的条,则不会出现问题。但其他的,比如相互合并的条形
标签: python matplotlib bar-chart python-ggplot