Update python_visual.py
parent
967c2b4e45
commit
1b7d754590
|
@ -12,8 +12,8 @@ import matplotlib.font_manager as fm
|
||||||
from mpl_toolkits.mplot3d import Axes3D
|
from mpl_toolkits.mplot3d import Axes3D
|
||||||
|
|
||||||
# 解决中文乱码问题
|
# 解决中文乱码问题
|
||||||
# myfont = fm.FontProperties(fname="/Library/Fonts/Songti.ttc", size=14)
|
myfont = fm.FontProperties(fname="/Library/Fonts/Songti.ttc", size=14)
|
||||||
# matplotlib.rcParams["axes.unicode_minus"] = False
|
matplotlib.rcParams["axes.unicode_minus"] = False
|
||||||
|
|
||||||
|
|
||||||
def simple_plot():
|
def simple_plot():
|
||||||
|
@ -26,19 +26,16 @@ def simple_plot():
|
||||||
|
|
||||||
# 生成画布,并设定标题
|
# 生成画布,并设定标题
|
||||||
plt.figure(figsize=(8, 6), dpi=80)
|
plt.figure(figsize=(8, 6), dpi=80)
|
||||||
# plt.title("简单曲线图", fontproperties=myfont)
|
plt.title("简单曲线图", fontproperties=myfont)
|
||||||
plt.title("简单曲线图")
|
|
||||||
plt.grid(True)
|
plt.grid(True)
|
||||||
|
|
||||||
# 设置X轴
|
# 设置X轴
|
||||||
# plt.xlabel("X轴", fontproperties=myfont)
|
plt.xlabel("X轴", fontproperties=myfont)
|
||||||
plt.xlabel("X轴")
|
|
||||||
plt.xlim(-4.0, 4.0)
|
plt.xlim(-4.0, 4.0)
|
||||||
plt.xticks(np.linspace(-4, 4, 9, endpoint=True))
|
plt.xticks(np.linspace(-4, 4, 9, endpoint=True))
|
||||||
|
|
||||||
# 设置Y轴
|
# 设置Y轴
|
||||||
# plt.ylabel("Y轴", fontproperties=myfont)
|
plt.ylabel("Y轴", fontproperties=myfont)
|
||||||
plt.ylabel("Y轴")
|
|
||||||
plt.ylim(-1.0, 1.0)
|
plt.ylim(-1.0, 1.0)
|
||||||
plt.yticks(np.linspace(-1, 1, 9, endpoint=True))
|
plt.yticks(np.linspace(-1, 1, 9, endpoint=True))
|
||||||
|
|
||||||
|
@ -47,7 +44,7 @@ def simple_plot():
|
||||||
plt.plot(x, y_sin, "g-", linewidth=2.0, label="sin示例")
|
plt.plot(x, y_sin, "g-", linewidth=2.0, label="sin示例")
|
||||||
|
|
||||||
# 设置图例位置,loc可以为[upper, lower, left, right, center]
|
# 设置图例位置,loc可以为[upper, lower, left, right, center]
|
||||||
# plt.legend(loc="upper left", prop=myfont, shadow=True)
|
plt.legend(loc="upper left", prop=myfont, shadow=True)
|
||||||
|
|
||||||
# 图形显示
|
# 图形显示
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
Loading…
Reference in New Issue