import matplotlib.pyplot
import numpy
import pandas

if __name__ == '__main__':
    dataframe = pandas.DataFrame(numpy.array([[1, 0.2, 10, 4], [2, 0.25, 8, 2], [3, 0.24, 8, 3], [4, 0.3, 6, 1]]),
                                 columns=["Day", "Price", "Count", "Like"])

    axes = dataframe.plot(x="Day", sharex=False, subplots=[("Price",), ("Count", "Like")], layout=(1, 2))
    axes[0, 0].set_ylabel("Price (unit: yuan)")
    axes[0, 1].set_ylabel("Count (unit: number)")

    matplotlib.pyplot.tight_layout()
    matplotlib.pyplot.show()

结果图:

2023-12-04T11:25:48.121639 image/svg+xml Matplotlib v3.8.0, https://matplotlib.org/
最后修改:2023 年 12 月 23 日
如果觉得我的文章对你有用,请随意赞赏