simple_axes_divider1
简单轴分割器示例1 123456789101112131415161718192021222324252627from mpl_toolkits.axes_grid1 import Size, Dividerimport matplotlib.pyplot as pltfig1 = plt.figure(1, (6, 6))# fixed size in inchhoriz = [Size.Fixed(1.), Size.Fixed(.5), Size.Fixed(1.5), Size.Fixed(.5)]vert = [Size.Fixed(1.5), Size.Fixed(.5), Size.Fixed(1.)]rect = (0.1, 0.1, 0.8, 0.8)# divide the axes rectangle into grid whose size is specified by horiz * vertdivider = Divider(fig1, rect, horiz, vert, aspect=False)# the rect parame...
simple_axes_divider2
简单轴分割器示例2 123456789101112131415161718192021222324252627import mpl_toolkits.axes_grid1.axes_size as Sizefrom mpl_toolkits.axes_grid1 import Dividerimport matplotlib.pyplot as pltfig1 = plt.figure(1, (5.5, 4.))# the rect parameter will be ignore as we will set axes_locatorrect = (0.1, 0.1, 0.8, 0.8)ax = [fig1.add_axes(rect, label="%d" % i) for i in range(4)]horiz = [Size.Scaled(1.5), Size.Fixed(.5), Size.Scaled(1.), Size.Scaled(.5)]vert = [Size.Scaled(1.), Size.Fixed(.5), Size...
simple_axesgrid
简单的轴线网格 12345678910111213141516import matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1 import ImageGridimport numpy as npim = np.arange(100).reshape((10, 10))fig = plt.figure(1, (4., 4.))grid = ImageGrid(fig, 111, # similar to subplot(111) nrows_ncols=(2, 2), # creates 2x2 grid of axes axes_pad=0.1, # pad between axes in inch. )for i in range(4): grid[i].imshow(im) # The AxesGrid object work as a list of axes.plt.show() 下载这个示例 下载pyth...
simple_axes_divider3
简单轴分割器示例3 123456789101112131415161718192021222324252627282930313233343536import mpl_toolkits.axes_grid1.axes_size as Sizefrom mpl_toolkits.axes_grid1 import Dividerimport matplotlib.pyplot as pltfig1 = plt.figure(1, (5.5, 4))# the rect parameter will be ignore as we will set axes_locatorrect = (0.1, 0.1, 0.8, 0.8)ax = [fig1.add_axes(rect, label="%d" % i) for i in range(4)]horiz = [Size.AxesX(ax[0]), Size.Fixed(.5), Size.AxesX(ax[1])]vert = [Size.AxesY(ax[0]), Size.Fixed(.5), Size.Ax...
simple_axesgrid2
简单的轴线网格2 1234567891011121314151617181920212223242526272829303132import matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1 import ImageGriddef get_demo_image(): import numpy as np from matplotlib.cbook import get_sample_data f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False) z = np.load(f) # z is a numpy array of 15x15 return z, (-3, 4, -4, 3)F = plt.figure(1, (5.5, 3.5))grid = ImageGrid(F, 111, # similar to subplot(111) nrows_...
simple_axisline4
简单的 Axisline4 1234567891011121314151617import matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1 import host_subplotimport numpy as npax = host_subplot(111)xx = np.arange(0, 2*np.pi, 0.01)ax.plot(xx, np.sin(xx))ax2 = ax.twin() # ax2 is responsible for "top" axis and "right" axisax2.set_xticks([0., .5*np.pi, np.pi, 1.5*np.pi, 2*np.pi])ax2.set_xticklabels(["$0$", r"$\frac{1}{2}\pi$", r"$\pi$", r"$\...
simple_colorbar
简单的彩色条实现 12345678910111213import matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1 import make_axes_locatableimport numpy as npax = plt.subplot(111)im = ax.imshow(np.arange(100).reshape((10, 10)))# create an axes on the right side of ax. The width of cax will be 5%# of ax and the padding between cax and ax will be fixed at 0.05 inch.divider = make_axes_locatable(ax)cax = divider.append_axes("right", size="5%", pad=0.05)plt.colorbar(im, cax=cax) 下载这个示例 下载python源码: simpl...
simple_rgb
简单的 RGB 1234567891011121314151617181920212223242526272829303132333435363738import matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1.axes_rgb import RGBAxesdef get_demo_image(): import numpy as np from matplotlib.cbook import get_sample_data f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False) z = np.load(f) # z is a numpy array of 15x15 return z, (-3, 4, -4, 3)def get_rgb(): Z, extent = get_demo_image() Z[Z < 0] = 0. Z = Z / Z.max()...
color_cycle_default
默认属性循环中的颜色显示默认prop_cycle中的颜色,该颜色是从rc参数中获取的。 123456789101112131415161718192021222324252627282930313233import numpy as npimport matplotlib.pyplot as pltprop_cycle = plt.rcParams['axes.prop_cycle']colors = prop_cycle.by_key()['color']lwbase = plt.rcParams['lines.linewidth']thin = lwbase / 2thick = lwbase * 3fig, axs = plt.subplots(nrows=2, ncols=2, sharex=True, sharey=True)for icol in range(2): if icol == 0: lwx, lwy = thin, lwbase else: lwx, lwy...
color_by_yvalue
通过y-value绘制颜色使用掩码数组以y值绘制具有不同颜色的线。 1234567891011121314151617import numpy as npimport matplotlib.pyplot as pltt = np.arange(0.0, 2.0, 0.01)s = np.sin(2 * np.pi * t)upper = 0.77lower = -0.77supper = np.ma.masked_where(s < upper, s)slower = np.ma.masked_where(s > lower, s)smiddle = np.ma.masked_where(np.logical_or(s < lower, s > upper), s)fig, ax = plt.subplots()ax.plot(t, smiddle, t, slower, t, supper)plt.show() 参考此示例中显示了以下函数,方法,类和模块的使用: 123import matplotlibmatplotlib.axes.Axes.plo...














