connectionstyle_demo
连接样式演示 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import matplotlib.pyplot as pltfig, axs = plt.subplots(3, 5, figsize=(8, 4.8))x1, y1 = 0.3, 0.3x2, y2 = 0.7, 0.7def demo_con_style(ax, connectionstyle, label=None): x1, y1 = 0.3, 0.2 x2, y2 = 0.8, 0.6 ax.plot([x1, x2], [y1, y2], ".") ax.annotate("", xy=(x1, y1), xycoords='data', xytext=(x2, y2), textcoords='data', ...
custom_boxstyle02
自定义Boxstyle02 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273from matplotlib.path import Pathfrom matplotlib.patches import BoxStyleimport matplotlib.pyplot as plt# we may derive from matplotlib.patches.BoxStyle._Base class.# You need to override transmute method in this case.class MyStyle(BoxStyle._Base): """ A simple box. """ def __init__(self, pad=0.3): ...
custom_boxstyle01
自定义Boxstyle01 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849from matplotlib.path import Pathdef custom_box_style(x0, y0, width, height, mutation_size, mutation_aspect=1): """ Given the location and size of the box, return the path of the box around it. - *x0*, *y0*, *width*, *height* : location and size of the box - *mutation_size* : a reference scale for the mutation. - *aspect_ratio* : aspect-ration for the mutat...
demo_gridspec01
Gridspec演示01 1234567891011121314151617181920import matplotlib.pyplot as pltdef make_ticklabels_invisible(fig): for i, ax in enumerate(fig.axes): ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center") ax.tick_params(labelbottom=False, labelleft=False)fig = plt.figure(0)ax1 = plt.subplot2grid((3, 3), (0, 0), colspan=3)ax2 = plt.subplot2grid((3, 3), (1, 0), colspan=2)ax3 = plt.subplot2grid((3, 3), (1, 2), rowspan=2)ax4 = plt.subplot2grid((3, 3)...
demo_gridspec03
Gridspec演示03 12345678910111213141516171819202122232425262728293031import matplotlib.pyplot as pltfrom matplotlib.gridspec import GridSpecdef make_ticklabels_invisible(fig): for i, ax in enumerate(fig.axes): ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center") ax.tick_params(labelbottom=False, labelleft=False)# demo 3 : gridspec with subplotpars set.fig = plt.figure()fig.suptitle("GridSpec w/ different subplotpars")gs1 = GridSpec(...
demo_gridspec05
Gridspec演示05 12345678910111213141516171819202122import matplotlib.pyplot as pltimport matplotlib.gridspec as gridspecdef make_ticklabels_invisible(fig): for i, ax in enumerate(fig.axes): ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center") ax.tick_params(labelbottom=False, labelleft=False)f = plt.figure()gs = gridspec.GridSpec(2, 2, width_ratios=[1, 2], height_ratios=[4, 1])ax1 = plt.subplot(gs[0])ax2 = plt.subplot(gs...
demo_gridspec06
Gridspec演示06 1234567891011121314151617181920212223242526272829303132333435363738394041424344import matplotlib.pyplot as pltimport matplotlib.gridspec as gridspecimport numpy as npfrom itertools import productdef squiggle_xy(a, b, c, d): i = np.arange(0.0, 2*np.pi, 0.05) return np.sin(i*a)*np.cos(i*b), np.sin(i*c)*np.cos(i*d)fig = plt.figure(figsize=(8, 8))# gridspec inside gridspecouter_grid = gridspec.GridSpec(4, 4, wspace=0.0, hspace=0.0)for i in range(16): inner_grid = gridspec.Gr...
pgf_fonts
Pgf字体 123456789101112131415161718import matplotlib.pyplot as pltplt.rcParams.update({ "font.family": "serif", "font.serif": [], # use latex default serif font "font.sans-serif": ["DejaVu Sans"], # use a specific sans-serif font})plt.figure(figsize=(4.5, 2.5))plt.plot(range(5))plt.text(0.5, 3., "serif")plt.text(0.5, 2., "monospace", family="monospace")plt.text(2.5, 2., "s...
pgf_preamble_sgskip
Pgf序言12345678910111213141516171819202122232425import matplotlib as mplmpl.use("pgf")import matplotlib.pyplot as pltplt.rcParams.update({ "font.family": "serif", # use serif/main font for text elements "text.usetex": True, # use inline math for ticks "pgf.rcfonts": False, # don't setup fonts from rc parameters "pgf.preamble": [ "\\usepackage{units}", # load additional ...
pgf_texsystem
Pgf文本系统 1234567891011121314151617181920import matplotlib.pyplot as pltplt.rcParams.update({ "pgf.texsystem": "pdflatex", "pgf.preamble": [ r"\usepackage[utf8x]{inputenc}", r"\usepackage[T1]{fontenc}", r"\usepackage{cmbright}", ]})plt.figure(figsize=(4.5, 2.5))plt.plot(range(5))plt.text(0.5, 3., "serif", family="serif")plt.text(0.5, 2., &...














