-sharp!/usr/bin/env python
-sharp -*- coding: utf-8 -*-
-sharp @Time : 18/2/26 12:52
-sharp @Author : AlexZ33
-sharp @File :
-sharp @Desc :
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
from mpl_toolkits.mplot3d import Axes3D
-sharp
myfont = fm.FontProperties(fname="/home/zk/study/python_lessions/DataVisualiztion/Library/Fonts/simsun.ttc", size=14)
matplotlib.rcParams["axes.unicode_minus"] = False
def simple_plot():
"""
simple plot
:return:
"""
-sharp
plt.figure(figsize=(8,6), dpi=80)
-sharp
plt.ion()
-sharp
for index in range(100):
-sharp
plt.cla()
-sharp
plt.title("",fontproperties=myfont)
plt.grid(True)
-sharp
x = np.linspace(-np.pi + index, np.pi+0.1*index, 256,endpoint=True)
y_cos, y_sin = np.cos(x),np.sin(x)
-sharp
plt.xlabel("x", fontproperties= myfont)
plt.xlim(-4 + 0.1*index,4 + 0.1*index)
plt.xticks(np.linspace(-4 + 0.1 * index, 4 + 0.1 * index, 9, endpoint=True))
-sharp Y
plt.ylabel("Y", fontproperties=myfont)
plt.ylim(-1.0, 1.0)
plt.yticks(np.linspace(-1, 1, 9, endpoint=True))
-sharp
plt.plot(x, y_cos, "b--", linewidth=2.0, label="cos")
plt.plot(x, y_sin, "g-", linewidth=2.0, label="sin")
-sharp ,loc[upper, lower, left, right, center]
plt.legend(loc="upper left", prop=myfont, shadow=True)
-sharp
plt.pause(0.1)
-sharp
plt.ioff()
-sharp
plt.show()
return
if __name__ == "__main__":
simple_plot()
plt.cla () clears the previously drawn lines
plt.cla()
how to clear the legend without affecting cos, sin dynamic drawing