我有历史上的棒球数据,我正试图在一个简单的matplotlib图中可视化,我想有一个表,显示过去一年的平均统计数据,每个统计的折线图,然后是一个独立计算的最终得分。在
在一个表中插入一个5xlib函数,这是可能的吗?如果没有,有什么关于我该怎么做的建议吗?我想我可以创建几个子窗口,但是格式化会很奇怪,而且不是很动态。感谢你的帮助。在
使用@TheImportanceofBeingErnest的代码,我在matplotlib中遇到了一个bug,在使用gridspec时看不到x轴:
fig = plt.figure(figsize=(8.5,11))
gs_row1left = gridspec.GridSpec(1,1)
gs_row1right = gridspec.GridSpec(1,1)
summaryplot2subplot(fig, gs_row1left[0], data, col1, col2, finalsc)
ax.axis('off')
ax2 = fig.add_subplot(gs_row1right[0, 0])
df = pd.DataFrame({'year':['2001-01','2002-01','2003-01','2004-01','2005-01'], 'value':[100,200,300,400,500]})
barax = ax2.twinx()
df['value1']= df['value']*0.4
df['value2'] = df['value']*0.6# Let them be strings!
df.plot(x = ['year'], y = ['value'], kind = 'line', ax = ax2)
df.plot(x = ['year'], y= ['value1','value2'], kind = 'bar', ax = barax)
gs_row1left.update(left = 0.05, right = 0.48)
gs_row1right.update(left = 0.55, right = 0.98)
plt.show()
无法将绘图插入matplotlib表中。然而,子块网格允许创建类似表的行为。在
要将多个这样的图放入一个图中,您可以使用一些不同的方法来创建一个包含多个子网格的gridspec。
相关问题 更多 >
编程相关推荐