pyplot_mathtext
Pyplot 数学文本(Mathtext)在文本标签中使用数学表达式。有关MathText的概述,请参阅编写数学表达式。 12345678910111213import numpy as npimport matplotlib.pyplot as pltt = np.arange(0.0, 2.0, 0.01)s = np.sin(2*np.pi*t)plt.plot(t,s)plt.title(r'$\alpha_i > \beta_i$', fontsize=20)plt.text(1, -0.6, r'$\sum_{i=0}^\infty x_i$', fontsize=20)plt.text(0.6, 0.6, r'$\mathcal{A}\mathrm{sin}(2 \omega t)$', fontsize=20)plt.xlabel('time (s)')plt.ylabel('volts (mV...
pyplot_scales
Pyplot 比例尺(Scales)在不同的比例上创建图。这里显示了线性,对数,对称对数和对数标度。有关更多示例,请参阅库的“缩放”部分。 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import numpy as npimport matplotlib.pyplot as pltfrom matplotlib.ticker import NullFormatter # useful for `logit` scale# Fixing random state for reproducibilitynp.random.seed(19680801)# make up some data in the interval ]0, 1[y = np.random.normal(loc=0.5, scale=0.4, size=1000)y = y[(y > 0) & (y < 1)]y.sort()x = np...
pyplot_simple
Pyplot 简单图(Simple)A most simple plot, where a list of numbers is plotted against their index. 1234import matplotlib.pyplot as pltplt.plot([1,2,3,4])plt.ylabel('some numbers')plt.show() 参考此示例显示了以下函数、方法、类和模块的使用: 1234import matplotlibmatplotlib.pyplot.plotmatplotlib.pyplot.ylabelmatplotlib.pyplot.show 下载这个示例 下载python源码: pyplot_simple.py 下载Jupyter notebook: pyplot_simple.ipynb
pyplot_text
Pyplot 文本(Text)1234567891011121314151617181920import numpy as npimport matplotlib.pyplot as plt# Fixing random state for reproducibilitynp.random.seed(19680801)mu, sigma = 100, 15x = mu + sigma * np.random.randn(10000)# the histogram of the datan, bins, patches = plt.hist(x, 50, density=True, facecolor='g', alpha=0.75)plt.xlabel('Smarts')plt.ylabel('Probability')plt.title('Histogram of IQ')plt.text(60, .025, r'$\mu=100,\ \sigma=15$')plt.axis([...
pyplot_three
Pyplot 绘制三条线在一次调用 plot 绘图中绘制三个线图。 123456789import numpy as npimport matplotlib.pyplot as plt# evenly sampled time at 200ms intervalst = np.arange(0., 5., 0.2)# red dashes, blue squares and green trianglesplt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')plt.show() 参考此示例显示了以下函数、方法、类和模块的使用: 123import matplotlibmatplotlib.pyplot.plotmatplotlib.axes.Axes.plot 下载这个示例 下载python源码: pyplot_three.py 下载Jupyter notebook: pyplot_three.ipynb
text_commands
绘制不同的文本绘制许多不同种类的文本。 1234567891011121314151617181920212223242526272829303132import matplotlib.pyplot as pltfig = plt.figure()fig.suptitle('bold figure suptitle', fontsize=14, fontweight='bold')ax = fig.add_subplot(111)fig.subplots_adjust(top=0.85)ax.set_title('axes title')ax.set_xlabel('xlabel')ax.set_ylabel('ylabel')ax.text(3, 8, 'boxed italics text in data coords', style='italic', bbox={'facecolor':...
pyplot_two_subplots
Pyplot 绘制两个子图使用pyplot.subplot创建带有两个子图的图形。 12345678910111213141516import numpy as npimport matplotlib.pyplot as pltdef f(t): return np.exp(-t) * np.cos(2*np.pi*t)t1 = np.arange(0.0, 5.0, 0.1)t2 = np.arange(0.0, 5.0, 0.02)plt.figure(1)plt.subplot(211)plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k')plt.subplot(212)plt.plot(t2, np.cos(2*np.pi*t2), 'r--')plt.show() 参考此示例中显示了以下函数,方法,类和模块的使用: 123import matplotlibmatplotlib.pyplot.figurematplotlib.pyplot.subplot 下载这个示例 下载...
text_layout
不同文本的布局创建具有不同对齐和旋转的文本。 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677import matplotlib.pyplot as pltimport matplotlib.patches as patches# build a rectangle in axes coordsleft, width = .25, .5bottom, height = .25, .5right = left + widthtop = bottom + heightfig = plt.figure()ax = fig.add_axes([0,0,1,1])# axes coordinates are 0,0 is bottom left and 1,1 is upper rightp = patches.Rectangle( (left,...
whats_new_1_subplot3d
1.0版本新特性:3d子图在同一图中创建两个三维图。 12345678910111213141516171819202122232425262728293031# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused importfrom matplotlib import cm#from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatterimport matplotlib.pyplot as pltimport numpy as npfig = plt.figure()ax = fig.add_subplot(1, 2, 1, projection='3d')X = np.arange(-5, 5, 0.25)Y = np.arange(-5, 5, 0.25)X, Y ...
whats_new_98_4_fancy
0.98.4版本新的炫酷特性创建精美的盒子和箭头样式。 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354import matplotlib.patches as mpatchimport matplotlib.pyplot as pltfigheight = 8fig = plt.figure(1, figsize=(9, figheight), dpi=80)fontsize = 0.4 * fig.dpidef make_boxstyles(ax): styles = mpatch.BoxStyle.get_styles() for i, (stylename, styleclass) in enumerate(sorted(styles.items())): ax.text(0.5, (float(len(styles)) - 0.5 - i)/len(styles), stylename, ...














