categorical_variables
绘制分类变量如何在Matplotlib中使用分类变量。 很多时候你想创建一个在Matplotlib中使用分类变量的图。Matplotlib允许你将分类变量直接传递给许多绘图函数,我们将在下面演示。 1234567891011import matplotlib.pyplot as pltdata = {'apples': 10, 'oranges': 15, 'lemons': 5, 'limes': 20}names = list(data.keys())values = list(data.values())fig, axs = plt.subplots(1, 3, figsize=(9, 3), sharey=True)axs[0].bar(names, values)axs[1].scatter(names, values)axs[2].plot(names, values)fig.suptitle('Categorical Plotting') ; 这...
cohere
绘制两个信号的相干性举例说明如何绘制两个信号的相干性。 123456789101112131415161718192021222324252627import numpy as npimport matplotlib.pyplot as plt# Fixing random state for reproducibilitynp.random.seed(19680801)dt = 0.01t = np.arange(0, 30, dt)nse1 = np.random.randn(len(t)) # white noise 1nse2 = np.random.randn(len(t)) # white noise 2# Two signals with a coherent part at 10Hz and a random parts1 = np.sin(2 * np.pi * 10 * t) + nse1s2 = np.sin(2 * np.pi * 10 * t) + nse2fig, axs = plt.s...
csd_demo
绘制两个信号交叉密度计算两个信号的交叉谱密度 ; 1234567891011121314151617181920212223242526272829303132333435import numpy as npimport matplotlib.pyplot as pltfig, (ax1, ax2) = plt.subplots(2, 1)# make a little extra space between the subplotsfig.subplots_adjust(hspace=0.5)dt = 0.01t = np.arange(0, 30, dt)# Fixing random state for reproducibilitynp.random.seed(19680801)nse1 = np.random.randn(len(t)) # white noise 1nse2 = np.random.randn(len(t)) # white noise 2r = np.exp(-t / 0.05)cnse...
errorbar_limits_simple
绘制限制型误差条形图误差条上的上限符号和下限符号的说明 12import numpy as npimport matplotlib.pyplot as plt 123456789101112131415fig = plt.figure(0)x = np.arange(10.0)y = np.sin(np.arange(10.0) / 20.0 * np.pi)plt.errorbar(x, y, yerr=0.1)y = np.sin(np.arange(10.0) / 20.0 * np.pi) + 1plt.errorbar(x, y, yerr=0.1, uplims=True)y = np.sin(np.arange(10.0) / 20.0 * np.pi) + 2upperlimits = np.array([1, 0] * 5)lowerlimits = np.array([0, 1] * 5)plt.errorbar(x, y, yerr=0.1, uplims=upperlimits, lolims=lowerlimits)plt.xlim(-1, 10) ...
eventcollection_demo
绘制事件集的示例绘制两条曲线,然后使用EventCollections标记每条曲线的相应轴上的x和y数据点的位置 ; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import matplotlib.pyplot as pltfrom matplotlib.collections import EventCollectionimport numpy as np# Fixing random state for reproducibilitynp.random.seed(19680801)# create random dataxdata = np.random.random([2, 10])# split the data into two partsxdata1 = xdata[0, :]xdata2 = xdata[1, :]# sort the data so it makes clean curvesxdata1.sort()xdat...
errorbar_subsample
绘制误差条形图子样本演示 errorevery 关键字,以显示数据的完全精度数据图与很少的误差条。 ; 12345678910111213141516171819202122232425import numpy as npimport matplotlib.pyplot as plt# example datax = np.arange(0.1, 4, 0.1)y = np.exp(-x)# example variable error bar valuesyerr = 0.1 + 0.1 * np.sqrt(x)# Now switch to a more OO interface to exercise more features.fig, axs = plt.subplots(nrows=1, ncols=2, sharex=True)ax = axs[0]ax.errorbar(x, y, yerr=yerr)ax.set_title('all errorbars')ax = axs[1]ax.errorbar(x, y, yerr=yerr, err...
fill
绘制填充图的示例演示填充图。 首先,用户可以使用matplotlib制作的最基本的填充图: 123456789import numpy as npimport matplotlib.pyplot as pltx = [0, 1, 2, 1]y = [1, 2, 1, 0]fig, ax = plt.subplots()ax.fill(x, y)plt.show() 接下来,还有一些可选功能: 使用单个命令的多条曲线。 设置填充颜色。 设置不透明度(alpha值)。 123456789101112131415x = np.linspace(0, 1.5 * np.pi, 500)y1 = np.sin(x)y2 = np.sin(3 * x)fig, ax = plt.subplots()ax.fill(x, y1, 'b', x, y2, 'r', alpha=0.3)# Outline of the region we've filled inax.plot(x, y1, c='b', alpha=0...
eventplot_demo
绘制plot事件图的示例一个事件图,显示具有各种线属性的事件序列。该图以水平和垂直方向显示。 ; 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556import matplotlib.pyplot as pltimport numpy as npimport matplotlibmatplotlib.rcParams['font.size'] = 8.0# Fixing random state for reproducibilitynp.random.seed(19680801)# create random datadata1 = np.random.random([6, 50])# set different colors for each set of positionscolors1 = np.array([[1, 0, 0], [0, 1, 0], ...
fill_between_demo
填充线条之间的区域此示例显示如何使用fill_between方法基于用户定义的逻辑在行之间着色。 123456import matplotlib.pyplot as pltimport numpy as npx = np.arange(0.0, 2, 0.01)y1 = np.sin(2 * np.pi * x)y2 = 1.2 * np.sin(4 * np.pi * x) 1234567891011fig, (ax1, ax2, ax3) = plt.subplots(3, 1, sharex=True)ax1.fill_between(x, 0, y1)ax1.set_ylabel('between y1 and 0')ax2.fill_between(x, y1, 1)ax2.set_ylabel('between y1 and 1')ax3.fill_between(x, y1, y2)ax3.set_ylabel('between y1 and y2')ax3.set_xlabel('x'...
filled_step
# 填充直方图 用于绘制直方图的剖面线功能。 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182import itertoolsfrom collections ...













