matplotlib pyplot绘制错误的y轴

时间:2019-07-30 19:15:24

标签: matplotlib

我正在使用pyplot绘制一个简单的图。但是,结果图未正确显示我的y值。如您所见,我的y值为[20.90249435665911,20.90801069518723]。但是,该图的y轴缩放比例为0.003至0.008。而且该图本身是完全错误的(由于我的y值非常接近,所以它应该是一条水平线)。请帮我!非常感谢!

def add_plot(plot_type, dic):
        memfile = BytesIO()

        y_list = []
        my_xticks = []

        for key in sorted(dic.keys()):
            my_xticks.append(key)
            y_list.append(dic[key])


        y = np.array(y_list)

        fig, ax = plt.subplots()
        for i,j in zip(my_xticks,y):
            ax.annotate(str(j),xy=(i,j))

        ax.plot(my_xticks, y)

        ax.set(xlabel='hour', ylabel='rpm',
            title='About as simple as it gets, folks')

        ax.grid()

        fig.savefig(memfile)

wrong plot

0 个答案:

没有答案
相关问题