1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 10 Python Matplotlib 绘制极坐标图和散点图

10 Python Matplotlib 绘制极坐标图和散点图

时间:2022-02-08 14:44:04

相关推荐

10 Python Matplotlib 绘制极坐标图和散点图

matplotlib 绘图实例

import numpy as npimport matplotlib.pyplot as pltimport matplotlibnp.random.seed(0)mu, sigma = 100, 20 # 均值和标准差a = np.random.normal(mu, sigma, size = 100)##plt.hist(a,20,histtype="stepfilled",facecolor="b",alpha=0.75)plt.hist(a, 40, histtype = 'stepfilled', facecolor = 'b', alpha = 0.75)plt.title('Histogram')plt.show()print(np.pi)

matplotlib 绘图极坐标图实例

N = 20theta = np.linspace(0.0, 2*np.pi, N, endpoint = False)radii = 10 * np.random.rand(N)print(radii)width = np.pi / 4 * np.random.rand(N)print(width)ax = plt.subplot(1,1,1, projection = 'polar')print(ax)bars = ax.bar(theta, radii, width = width, bottom = 0.0)for r, bar in zip(radii, bars):bar.set_facecolor(plt.cm.viridis(r/10))bar.set_alpha(0.5)plt.show()

matplotlib 绘图散点图实例(运用面向对象的方法)

help(plt.plot)fig, ax = plt.subplots()print(10*np.random.randn(100))ax.plot(10*np.random.randn(100), 10*np.random.randn(100),'o')ax.set_title('Simple Scatter')plt.show()

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。