使用ubuntu 18.04.1 lts python 3.6.7 matplotlib 2.1.1熊猫0.23.4 并尝试在折线图上绘制以下测试数据。因此,它应该以从10到50 100的点从左到右的线结束
the x_axes = hv_20 hv_10 hv_5
the y axes = 10 50 100
要绘制的SEEMS下面的代码
the x_axes = **hv_10 hv_20** hv_5
the y_axes = **50 10** 100
我不知道为什么,而且似乎找不到帮助我的文档。
我在做错什么吗?
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def mini_plot( data_frame ):
fig, axes = plt.subplots(nrows=20 , ncols=10, sharey=True, figsize=(10,5))
axes_list = [item for sublist in axes for item in sublist]
for index, row in data_frame.iterrows():
ax = axes_list.pop(0)
y_axes = pd.DataFrame(data_frame.iloc[ index ].values[3:6])
print("index = ", data_frame.iloc[ index ][3:6].index)
plt.ylim(0 , 100)
ax.set_xlabel(row.Symbol ,labelpad= 0 )
#x_axes = ['20', '10' , '5' ]
x_axes = data_frame.iloc[ index ][3:6].index
#ax.set_xticklabels( x_axes )
ax.plot( x_axes, y_axes , label = "min", color= 'g' , linestyle='solid', linewidth=0.5)
for ax in axes_list:
ax.remove()
plt.show()
if __name__ == '__main__' :
test_data = [ ('20181126#AAPL' , '2018-11-26', 'AAPL' , 10, 50, 100) ]
test_labels = [ 'Id', 'Date' , 'Symbol' , 'Hv_20' , 'Hv_10', 'Hv_5' ]
df_todays_data = pd.DataFrame.from_records( test_data , columns = test_labels)
mini_plot( df_todays_data )
答案 0 :(得分:0)
@t。先生回答了我的问题。我使用的是旧版本的matplotlib 2.1.1,而当前版本为IS 3.0.x,因此将更新应用到了系统和BINGO中!
pip3 install --upgrade matplotlib