Y轴摇杆位于混乱的Matplotlib中

时间:2018-10-21 11:27:23

标签: python python-3.x matplotlib

当我使用matplotlib创建图形时,Y轴摇杆处于无序状态,如下图所示:Show the error。如何解决此问题?我的代码来生成我的情节:

def create_graphe(data):
   date = []
   followers = []
   following = []
   ratio = []
   for obj in data:
       date.append(obj[0])
       followers.append(obj[1])
       following.append(obj[2])
       ratio.append(obj[3])
   plt.style.use('ggplot')
   plt.subplot(3, 1, 1)
   plt.plot(date,followers, label="Followers")

   plt.xticks([])
   plt.legend()
   plt.subplot(3, 1, 2)
   plt.plot(date,following, label="Following")
   plt.xticks([])
   plt.legend()
   plt.subplot(3, 1, 3)
   plt.plot(date,ratio, label="Ratio")
   #plt.gca().invert_yaxis()
   plt.xticks([])
   plt.legend()
   plt.show()

0 个答案:

没有答案