demo_fixed_size_axes
演示固定尺寸轴 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1 import Divider, Sizefrom mpl_toolkits.axes_grid1.mpl_axes import Axesdef demo_fixed_size_axes(): fig1 = plt.figure(1, (6, 6)) # The first items are for padding and the second items are for the axes. # sizes are in inch. h = [Size.Fixed(1.0), Size.Fixed(4.5)] v = [Size.Fixed(0.7), Size.Fixed(5.)] divider = Divider(fig1, ...
demo_imagegrid_aspect
演示Imagegrid Aspect 1234567891011121314151617181920import matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1 import ImageGridfig = plt.figure(1)grid1 = ImageGrid(fig, 121, (2, 2), axes_pad=0.1, aspect=True, share_all=True)for i in [0, 1]: grid1[i].set_aspect(2)grid2 = ImageGrid(fig, 122, (2, 2), axes_pad=0.1, aspect=True, share_all=True)for i in [1, 3]: grid2[i].set_aspect(2)plt.show() 下载这个示例 下载python源码: demo_imagegrid_aspect.py 下载Jupyter notebook: de...
inset_locator_demo2
插入定位器演示2本演示展示了如何通过 zoomed_inset_axes 创建缩放插图。 在第一个子图中,AnchoredSizeBar 显示缩放效果。 在第二个子图中,通过mark_inset 创建与感兴趣区域的连接。 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576import matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes, mark_insetfrom mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBarimport numpy as npdef get_demo_image(): from matplotlib.cbook...
demo_edge_colorbar
演示Edge Colorbar 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687import matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1 import AxesGriddef 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, (...
inset_locator_demo
插入定位器演示inset_locator 的 inset_axes 允许通过指定宽度和高度以及可选地将位置(Loc)接受位置作为代码(类似于图例),轻松地在轴的角中放置插入。默认情况下,通过“边界板”(BorderPad)参数控制的内嵌与轴之间的某些点偏移。 12345678910111213141516171819202122232425262728import matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1.inset_locator import inset_axesfig, (ax, ax2) = plt.subplots(1, 2, figsize=[5.5, 2.8])# Create inset of width 1.3 inches and height 0.9 inches# at the default upper right locationaxins = inset_axes(ax, width=1.3, height=0.9)# Create inset of width 30% and heig...
make_room_for_ylabel_using_axesgrid
使用Axesgrid为Ylabel腾出空间 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061from mpl_toolkits.axes_grid1 import make_axes_locatablefrom mpl_toolkits.axes_grid1.axes_divider import make_axes_area_auto_adjustableif __name__ == "__main__": import matplotlib.pyplot as plt def ex1(): plt.figure(1) ax = plt.axes([0, 0, 1, 1]) #ax = plt.subplot(111) ax.set_yticks([0.5]) ax.set_yticklabels(...
parasite_simple2
简单寄生示例2 1234567891011121314151617181920212223242526272829303132333435363738394041import matplotlib.transforms as mtransformsimport matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1.parasite_axes import SubplotHostobs = [["01_S1", 3.88, 0.14, 1970, 63], ["01_S4", 5.6, 0.82, 1622, 150], ["02_S1", 2.4, 0.54, 1570, 40], ["03_S1", 4.1, 0.62, 2380, 170]]fig = plt.figure()ax_kms = SubplotHost(fig, 1, 1, 1, aspect=1.)# angular proper motion...
parasite_simple
简单寄生示例 1234567891011121314151617181920212223from mpl_toolkits.axes_grid1 import host_subplotimport matplotlib.pyplot as plthost = host_subplot(111)par = host.twinx()host.set_xlabel("Distance")host.set_ylabel("Density")par.set_ylabel("Temperature")p1, = host.plot([0, 1, 2], [0, 1, 2], label="Density")p2, = par.plot([0, 1, 2], [0, 3, 2], label="Temperature")leg = plt.legend()host.yaxis.get_label().set_color(p1.get_color())leg.texts[0].set_color(...
simple_anchored_artists
简单锚定艺术家对象示例此示例说明如何使用在 offsetbox 和 Matplotlib axes_grid1 Toolkit 中找到的锚定辅助对象类。类似图形的实现,但不使用工具包,可以在锚定的艺术家对象中找到。 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273import matplotlib.pyplot as pltdef draw_text(ax): """ Draw two text-boxes, anchored by different corners to the upper-left corner of the figure. """ from matplotlib.offsetbox import AnchoredText at = Anc...
scatter_hist_locatable_axes
散点图 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748import numpy as npimport matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1 import make_axes_locatable# Fixing random state for reproducibilitynp.random.seed(19680801)# the random datax = np.random.randn(1000)y = np.random.randn(1000)fig, axScatter = plt.subplots(figsize=(5.5, 5.5))# the scatter plot:axScatter.scatter(x, y)axScatter.set_aspect(1.)# create new axes on the right and on the top of the cu...














