python学习日记六——浅拷贝 深拷贝 以及matplotlib

浅拷贝 深拷贝:https://www.cnblogs.com/wilber2013/p/4645353.html
matplotlib: https://matplotlib.org/index.html
https://matplotlib.org/gallery/index.html

在使用了matplotlib中的交互开关
ion()之后,由于print的plot是在console命令行中,无法动态显示和刷新图片
需要在命令行中使用>matplotlib,并运行,图片就不在console里显示,而是跳出一个窗口显示,这样就可以动态显示了。
如果想切换回图片在console里显示,就运行%matplotlib inline。
画一幅直线移动的动画,设定坐标范围

import numpy as np
import matplotlib.pyplot as plt
plt.ion()
sample_X=[1,2,3,4,5]
sample_Y=[0,1,2,3,4]
fig = plt.subplot()
fig.set_yscale(‘linear’)
fig.set_ylim(0,20)
fig.set_yticks(np.arange(0,20,3))
plt.plot(sample_X,sample_Y)
for i in range(150):
plt.cla()
for j in range(5):#每个元素加0.1
sample_Y[j]=sample_Y[j]+0.1
fig.set_ylim(0,20)
plt.plot(sample_X,sample_Y,‘r-’,lw=3)
plt.pause(0.1)

猜你喜欢

转载自blog.csdn.net/weixin_43387285/article/details/83242127