fill_betweenx_demo
betweenx填充示例使用fill_betweenx在两条水平曲线之间着色。 12345678910111213141516171819202122232425262728293031323334353637383940414243import matplotlib.pyplot as pltimport numpy as npy = np.arange(0.0, 2, 0.01)x1 = np.sin(2 * np.pi * y)x2 = 1.2 * np.sin(4 * np.pi * y)fig, [ax1, ax2, ax3] = plt.subplots(3, 1, sharex=True)ax1.fill_betweenx(y, 0, x1)ax1.set_ylabel('(x1, 0)')ax2.fill_betweenx(y, x1, 1)ax2.set_ylabel('(x1, 1)')ax3.fill_betweenx(y, x1, x2)ax3.set_ylabel('(x1, x2)')ax...
horizontal_bar_chart
水平条形图这个例子展示了一个简单的水平条形图。 ; 12345678910111213141516171819202122232425import matplotlib.pyplot as pltimport numpy as np# Fixing random state for reproducibilitynp.random.seed(19680801)plt.rcdefaults()fig, ax = plt.subplots()# Example datapeople = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')y_pos = np.arange(len(people))performance = 3 + 10 * np.random.rand(len(people))error = np.random.rand(len(people))ax.barh(y_pos, performance, xerr=error, align=...
gradient_bar
渐变条形图 1234567891011121314151617181920212223242526272829import matplotlib.pyplot as pltimport numpy as npnp.random.seed(19680801)def gbar(ax, x, y, width=0.5, bottom=0): X = [[.6, .6], [.7, .7]] for left, top in zip(x, y): right = left + width ax.imshow(X, interpolation='bicubic', cmap=plt.cm.Blues, extent=(left, right, bottom, top), alpha=1)xmin, xmax = xlim = 0, 10ymin, ymax = ylim = 0, 1fig, ax = plt.subplots()ax.set(xlim=xlim, ylim=ylim, autos...
interp_demo
插补示例 123456789101112import matplotlib.pyplot as pltimport numpy as npx = np.linspace(0, 2 * np.pi, 20)y = np.sin(x)yp = Nonexi = np.linspace(x[0], x[-1], 100)yi = np.interp(xi, x, y, yp)fig, ax = plt.subplots()ax.plot(x, y, 'o', xi, yi, '.')plt.show() 下载这个示例 下载python源码: interp_demo.py 下载Jupyter notebook: interp_demo.ipynb
line_demo_dash_control
自定义虚线样式通过破折号序列控制线的划线。 它可以使用Line2D.set_dashes进行修改。 破折号序列是一系列点的开/关长度,例如 [3,1]将是由1pt空间隔开的3pt长线。 像Axes.plot 这样的函数支持将Line属性作为关键字参数传递。 在这种情况下,您可以在创建线时设置划线。 注意:也可以通过property_cycle配置破折号样式,方法是使用关键字破折号将破折号序列列表传递给循环器。这个例子中没有显示。 1234567891011121314151617import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0, 10, 500)y = np.sin(x)fig, ax = plt.subplots()# Using set_dashes() to modify dashing of an existing lineline1, = ax.plot(x, y, label='Using set_dashes()')line1.set_dashes([...
joinstyle
连接图样式举例说明三种不同的连接样式。 123456789101112131415161718192021222324import numpy as npimport matplotlib.pyplot as pltdef plot_angle(ax, x, y, angle, style): phi = np.radians(angle) xx = [x + .5, x, x + .5*np.cos(phi)] yy = [y, y, y + .5*np.sin(phi)] ax.plot(xx, yy, lw=8, color='blue', solid_joinstyle=style) ax.plot(xx[1:], yy[1:], lw=1, color='black') ax.plot(xx[1::-1], yy[1::-1], lw=1, color='black') ax.plot(xx[1:2], yy[1:2], 'o', color=...
linestyles
线的样式这个例子展示了复制Tikz / PGF的不同线条样式。 123456789101112131415161718192021222324252627282930313233343536373839404142434445import numpy as npimport matplotlib.pyplot as pltfrom collections import OrderedDictfrom matplotlib.transforms import blended_transform_factorylinestyles = OrderedDict( [('solid', (0, ())), ('loosely dotted', (0, (1, 10))), ('dotted', (0, (1, 5))), ('densely dotted', (0, (1, 1))), ...
line_styles_reference
线型样式参考Matplotlib附带的线型参考。 1234567891011121314151617181920212223242526import numpy as npimport matplotlib.pyplot as pltcolor = 'cornflowerblue'points = np.ones(5) # Draw 5 points for each linetext_style = dict(horizontalalignment='right', verticalalignment='center', fontsize=12, fontdict={'family': 'monospace'})def format_axes(ax): ax.margins(0.2) ax.set_axis_off()# Plot all line styles.fig, ax = plt.subplots()...
marker_fillstyle_reference
标记填充样式Matplotlib中包含的标记填充样式的参考。 另请参阅 标记填充样式 和标记路径示例。 123456789101112131415161718192021222324252627import numpy as npimport matplotlib.pyplot as pltfrom matplotlib.lines import Line2Dpoints = np.ones(5) # Draw 3 points for each linetext_style = dict(horizontalalignment='right', verticalalignment='center', fontsize=12, fontdict={'family': 'monospace'})marker_style = dict(color='cornflowerblue', linestyle=':'...
marker_reference
标记参考使用Matplotlib参考填充,未填充和自定义标记类型。 有关所有标记的列表,请参阅 matplotlib.markers 文档。 另请参阅 标记填充样式 和 标记路径示例。 123456789101112131415161718192021222324252627282930import numpy as npimport matplotlib.pyplot as pltfrom matplotlib.lines import Line2Dpoints = np.ones(3) # Draw 3 points for each linetext_style = dict(horizontalalignment='right', verticalalignment='center', fontsize=12, fontdict={'family': 'monospace'})marker_style = dict(linestyle=&...














