画图软件千千万,这个对比一下matlab与python的一个插件matplotlib作图质量。

直接上代码:

  • matlab下的代码:
%幂函数
x = linspace(-4,4,200);
f1 = 10.^x;
f2 = exp(x);
f3 = 2.^x;

plot(x, f1, 'r', x, f2, 'b', x, f3, 'g', 'LineWidth', 2);
axis([-4, 4, -0.5, 8])
text('Interpreter','latex','String','$10^x$', 'Position', [1, 7.5],'fontsize', 16)
text('Interpreter','latex','String','$e^x$', 'Position', [2.2, 7.5],'fontsize', 16)
text('Interpreter','latex','String','$2^x$', 'Position', [3.2, 7.5],'fontsize', 16)
  • python下的代码:
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-4, 4, 200)
f1 = np.power(10, x)
f2 = np.power(np.e, x)
f3 = np.power(2, x)

plt.plot(x, f1, 'r', x, f2, 'b', x, f3, 'g', linewidth = 2)
plt.axis([-4, 4, -0.5, 8])
plt.text(1, 7.5, r'$10^x$', fontsize = 16)
plt.text(2.2, 7.5, r'$e^x$', fontsize = 16)
plt.text(3.2, 7.5, r'$2^x$', fontsize = 16)

plt.show()

结果如下:

【Matlab】matlab与matplotlib作图比较
【Matlab】matlab与matplotlib作图比较
可以看到matlab画出来的图有更多的锯齿现象,python下matplotlib画出来的效果更好。

相关文章:

  • 2021-05-14
  • 2022-02-08
  • 2021-10-30
  • 2021-09-18
  • 2021-06-19
  • 2021-12-10
  • 2022-12-23
  • 2021-10-09
猜你喜欢
  • 2022-12-23
  • 2021-11-14
  • 2021-08-19
  • 2021-07-23
  • 2021-11-15
  • 2021-07-20
  • 2021-09-02
相关资源
相似解决方案