无框架双轴图表

时间:2018-12-24 14:24:08

标签: python matplotlib

我会尝试绘制带有双轴且没有框架的图表,但是如果我使用frameon = False函数,我仍然会得到带有框架的图表。可能是什么问题呢?如果我用一个斧头制作一个图表,那么它就可以工作。我的代码:

fig  = plt.subplots(1, figsize =(17,21))

ax1 = plt.subplot2grid((10, 10), (0, 0), rowspan= 2,colspan=4,frameon=False)
ax1_tw = ax1.twinx()
ax1.plot(data[['SPX500']],  linewidth=1.5, linestyle=('-'))
ax1_tw.plot(data[['VIX_Close']] ,'k',  linewidth=1.5, linestyle=('-'))
ax1_tw.plot(data[['VIX_Close_avg']] ,'orange',  linewidth=1.5, linestyle=(':'))
ax1.set(title='SP500')
ax1.set(xlabel='Date')
ax1.set(ylabel='SP500')
ax1_tw.set(ylabel='VIX')
ax1_tw.xaxis.set_major_locator(MaxNLocator(5))
ax1.legend(('SP500',),loc=2, frameon=False)
ax1_tw.legend(('VIX',),loc=1, frameon=False)
ax1_tw.xaxis.set_major_formatter(myFmt)

plt.show()

结果是:enter image description here

1 个答案:

答案 0 :(得分:2)

我猜这里有一个误会。问题是Log4j不适用于轴框架,但不适用于图例框的框架。下面是一个解释它的示例。

带有<value>hdfs://localhost:9000</value> 的数字

<value>hdfs://ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws:9000</value>

enter image description here

带有width = getResources().getDisplayMetrics().widthPixels; height = getResources().getDisplayMetrics().heightPixels; padding = (int) (width * 0.20); // offset from edges of the map - 20% of screen CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds,, width, height, padding); 的数字

frameon=False

enter image description here

您需要的是使用来关闭轴(您可以根据需要打开图例框架)

frameon=True

enter image description here