zoukankan      html  css  js  c++  java
  • 【Matlab】matlab与matplotlib作图比较

    matlab与matplotlib作图比较

    画图软件千千万,这个对比一下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
    matplotlib
    可以看到matlab画出来的图有更多的锯齿现象,python下matplotlib画出来的效果更好。

  • 相关阅读:
    markdown
    显示数学公式
    iOS----时间日期处理
    OC中文件读取类(NSFileHandle)介绍和常用使用方法
    深刻理解----修饰变量----关键字
    iOS----轻松掌握AFN网络顶级框架
    iOS
    iOS--多线程之线程间通讯
    iOS--多线程之NSOperation
    iOS--多线程之GCD
  • 原文地址:https://www.cnblogs.com/shanchuan/p/8150348.html
Copyright © 2011-2022 走看看