import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
bar_fig=plt.figure(figsize=(10,8))
bar_ax1=bar_fig.add_subplot(2,1,1)
df=pd.DataFrame(np.random.randint(1,21,size=(6,4)),
index=['one','two','three','four','five','six'],
columns=pd.Index([*'ABCD'],name='Genus'))
bar1_df=df.plot.bar(ax=bar_ax1)
bar_ax2=bar_fig.add_subplot(2,1,2)
bar2_df=df.plot.barh(ax=bar_ax2)
bar_fig.show()
![](http://tiebapic.baidu.com/forum/w%3D580/sign=7efe9b6e5d90f60304b09c4f0913b370/224bd60735fae6cd8ff5bc3e18b30f2443a70f88.jpg?tbpicau=2025-02-23-05_454aad7ef846ec98b66cd995b382805c)
像这种直接用DataFrame生成的图,而不是用x,y指定坐标轴这种情况,如果能像非子图情况使用
b=bar
xtips=b(1).XEndPoints
这样获得对应柱状图的x坐标啊。
求教,谢谢。
import numpy as np
import pandas as pd
bar_fig=plt.figure(figsize=(10,8))
bar_ax1=bar_fig.add_subplot(2,1,1)
df=pd.DataFrame(np.random.randint(1,21,size=(6,4)),
index=['one','two','three','four','five','six'],
columns=pd.Index([*'ABCD'],name='Genus'))
bar1_df=df.plot.bar(ax=bar_ax1)
bar_ax2=bar_fig.add_subplot(2,1,2)
bar2_df=df.plot.barh(ax=bar_ax2)
bar_fig.show()
![](http://tiebapic.baidu.com/forum/w%3D580/sign=7efe9b6e5d90f60304b09c4f0913b370/224bd60735fae6cd8ff5bc3e18b30f2443a70f88.jpg?tbpicau=2025-02-23-05_454aad7ef846ec98b66cd995b382805c)
像这种直接用DataFrame生成的图,而不是用x,y指定坐标轴这种情况,如果能像非子图情况使用
b=bar
xtips=b(1).XEndPoints
这样获得对应柱状图的x坐标啊。
求教,谢谢。