Using python “matplotlib.pyplot“ draw a beautiful picture

2024-01-08 06:03:32

DONNOT USE PLT FOR ANYTHING, INSTEAD FIGURE AND AX

Don not use the one below

plt.plot(your data)
plt.(xxxx) # xxxxs are the operations of plt
plt.show() # static show method, different from figure.show()

the easy version

figure = plt.figure() # there is a param called figsize= many inches
ax1 = figure.add_subplot(121) # rows columns index
ax1.plot(your data )
ax2 = figure.add_subplot(122) # rows columns index
ax2.plot(your data)
plt.show() # static show method, different from figure.show()

a mostly used one

figure, axes = plt.subplots(2, 1)
axes[0].plot([1, 2, 3], [1, 2, 3])
axes[1].plot([2, 2, 3], [1, 2, 3])
plt.show()

However, when I use this method in pycharm, axes[0].(xxxx), xxxxs are not be prompted, which is not a good one to use when you are a green hand one in programing.

文章来源:https://blog.csdn.net/YingShen_xyz/article/details/135446559
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。