MatPlotLib如何使打印放大和缩小

2024-10-04 03:16:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我不熟悉Python和数据可视化,问题是:我有一个用点和标签构建的绘图,但由于点之间的范围通常太高,但在一个groop中太低,所以有一个严重的ovellapping=((可以在图像上看到).有人能为这种情况推荐一个好的python可视化库吗?或者是一个解决方案,我如何放大/缩小这些组以显示更近的距离?谢谢。我知道axis的标签被弄乱了

Generated plot

这就是我想象我的情节的方式:

 # here we concatinate set of arrays using numpy to display they in the graph
    allAvg = np.concatenate((df['Avg']), axis=None)
    allYears = np.concatenate((df['Year']), axis=None)
    allStocs = np.concatenate((df['Stock']), axis=None)

    minValueAvg = min(allAvg)
    maxValueAvg = max(allAvg)
    start = time.time()
    print("Time taken to build plot")
    for ind, type in enumerate(df['Stock']):
        start = time.time()
        print("Time taken to go through one Stock and put it on a plot")
        for i, z in enumerate(df['Avg'][ind]):
            x = allAvg[i]
            y = allYears[i]
            plt.scatter(x, y, alpha=0.5, marker='D', color='green')
            plt.text(x + 0.1, y + 0.1, type, fontsize=4)
            end = time.time()
            print(end - start)
    plt.xlabel('Year')
    plt.ylabel('Average Adjustment Close Price')
    plt.title('Stock market graph')
    plt.legend()
    # show plot right away
    plt.show()

Tags: toinnonedftimeplot可视化stock