1、普通风格

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 2*np.pi, 50)
y1 = np.sin(x)
y2 = np.cos(x)
xticks=[0, np.pi/2, np.pi, 3*np.pi/2, 2*np.pi]

plt.figure('赏尔')

plt.plot(x, y1, c='g', marker='.', ls='--', label='sin(x)')
plt.plot(x, y2, 'y.--', label='cos(x)')
plt.xlabel('x')
plt.ylabel('sin/cos')
plt.xticks(xticks,)
plt.legend()

plt.show()

图形

matplotlib 绘制正余弦曲线图

 

 2、添加修饰

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 2*np.pi, 50)
y1 = np.sin(x)
y2 = np.cos(x)
xticks=[0, np.pi/2, np.pi, 3*np.pi/2, 2*np.pi]

plt.figure('赏尔', facecolor='azure')

plt.plot(x, y1, c='g', marker='p', ls='--',
         mec='r', mfc='g', ms=7, mew=0.71,
         label='sin(x)')
plt.plot(x, y2, 'yp--', mec='r', mfc='gold', ms=7, mew=0.72,
         label='cos(x)')
plt.xlabel('x')
plt.ylabel('sin/cos')
plt.xticks(xticks)
plt.legend()

plt.show()

图形

matplotlib 绘制正余弦曲线图

。。。

相关文章:

  • 2021-09-13
  • 2021-11-03
  • 2021-07-11
  • 2021-06-04
  • 2021-04-19
  • 2021-09-27
  • 2021-08-05
  • 2022-12-23
猜你喜欢
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
  • 2021-10-02
相关资源
相似解决方案