利用Python Matlab绘制曲线图的实例分析,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
我们在这里采用Python中的matplotlib来实现曲线图形的绘制。matplotlib是著名的python绘图库,它提供了一整套绘图API,十分适合交互式绘图。
代码:
具体的绘制的代码如下所示:
import matplotlib.pyplot as plt import numpy as np r = np.array([2072.54, 2076.84, 2085.51, 2103.01, 2129.93, 2162.16, 2200.22, 2242.15, 2285.71, 2328.29, 2350.18, 2364.01, 2364.01, 2343.29, 2300.17, 2252.25, 2208.72, 2166.85, 2132.19, 2103.01, 2085.51, 2075.77, 2072.54]) b_ = np.array([30.159, 27.143, 24.127, 21.111, 18.096, 15.080, 12.064, 9.048, 6.032, 3.016, 1.508, 0, -1.508, -3.016, -6.032, -9.048, -12.064, -15.080, -18.096, -21.111, -24.127, -27.143, -30.159]) b = b_ * pow(10, -4) plt.plot(b, r) plt.xlabel("B/T") plt.ylabel("R/Ω") plt.title("GMB R-B (decreasing B)") plt.show()
效果:
代码:
代码与上一个的代码其实是比较相似的:
import matplotlib.pyplot as plt import numpy as np r = np.array([2072.53, 2076.81, 2085.47, 2103.00, 2129.90, 2162.11, 2200.20, 2242.06, 2285.66, 2328.24, 2350.13, 2364.00, 2363.96, 2343.19, 2300.20, 2252.29, 2208.76, 2166.89, 2132.20, 2103.05, 2085.50, 2075.81, 2072.56]) b_ = np.array([30.159, 27.143, 24.127, 21.111, 18.096, 15.080, 12.064, 9.048, 6.032, 3.016, 1.508, 0, -1.508, -3.016, -6.032, -9.048, -12.064, -15.080, -18.096, -21.111, -24.127, -27.143, -30.159]) b = b_ * pow(10, -4) plt.plot(b, r) plt.xlabel("B/T") plt.ylabel("R/Ω") plt.title("GMB R-B (increasing B)") plt.show()
效果:
代码:
代码基本是形同的啦:
import matplotlib.pyplot as plt import numpy as np v = np.array([274, 270, 261, 243, 219, 189, 155, 118, 81, 48, 34, 21]) b_ = np.array([30.159, 27.143, 24.127, 21.111, 18.096, 15.080, 12.064, 9.048, 6.032, 3.016, 1.508, 0]) b = b_ * pow(10, -4) plt.plot(b, v) plt.xlabel("B/T") plt.ylabel("V/mV") plt.title("GMB V-B") plt.show()
效果:
代码:
代码其实都是基本一样的,只不过主要是更换了数据啦:
import matplotlib.pyplot as plt import numpy as np w = np.array([43.5, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86, 89, 92, 95, 98, 101, 104]) v = np.array([0, 5.7, 35.0, 53.8, 45.9, 7.7, -45.7, -51.9, -32.6, -1.8, 34.5, 53.1, 39.2, -10.1, -47.9, -51.4, -29.5, 5.6, 34.4, 52.4, 40.9, -5.2]) plt.plot(w, v) plt.xlabel("θ/rad") plt.ylabel("V/mV") plt.title("GMB V-θ") plt.show()
效果:
import numpy as np import matplotlib.pyplot as plt X = np.linspace(-4, 4, 1024) Y = .25 * (X + 4.) * (X + 1.) * (X - 2.) plt.title('$f(x)=\\frac{1}{4}(x+4)(x+1)(x-2)$') plt.plot(X, Y, c = 'g') plt.show()
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注亿速云行业资讯频道,感谢您对亿速云的支持。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。