你好。我现在正在绘制年线和数字字典数据的线形图。 当我试图通过使用matplotlib.pyplot绘制线图,它的轴线连续地固定0
例如,我想从dictonary( year_counts = {“2013”绘制曲线图:7,“2014” :20,'2015':10,'2016':37,'2017':1}).But其坐标轴从0开始并增加1. 尽管我设置了x极限, plt.xlim(xmin = int(years [0]))或 plt.axis([int(years [0]),int(years [-1]),0,max(book_counts)]) 它不起作用。
如何在2013年启动x轴?
这是我用
year_counts= {'2013':7, '2014':20, '2015':10, '2016':37, '2017':1}
years = sorted(year_counts)
book_counts = [year_counts[year] for year in years]
plt.plot(years, book_counts)
plt.xlim(xmin=int(years[0])) # didn't work
plt.axis([int(years[0]), int(years[-1]), 0, max(book_counts)]) # didn't work
plt.show()
http://matplotlib.org/examples/pylab_examples/spine_placement_demo.html#pylab-examples-example-code-spine-placement-demo- py – wwii
[Matplotlib中的中心原点]可能的重复(http://stackoverflow.com/questions/4694478/center-origin-in-matplotlib) – wwii
好的我会检查它 – dizwe