MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / create_axis_grid

Function create_axis_grid

DemoPrograms/Demo_Matplotlib_Styles.py:29–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27
28
29def create_axis_grid():
30 from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
31
32 plt.close('all')
33
34 def get_demo_image():
35 # prepare image
36 delta = 0.5
37
38 extent = (-3, 4, -4, 3)
39 x = np.arange(-3.0, 4.001, delta)
40 y = np.arange(-4.0, 3.001, delta)
41 X, Y = np.meshgrid(x, y)
42 Z1 = np.exp(-X ** 2 - Y ** 2)
43 Z2 = np.exp(-(X - 1) ** 2 - (Y - 1) ** 2)
44 Z = (Z1 - Z2) * 2
45
46 return Z, extent
47
48 def get_rgb():
49 Z, extent = get_demo_image()
50
51 Z[Z < 0] = 0.
52 Z = Z / Z.max()
53
54 R = Z[:13, :13]
55 G = Z[2:, 2:]
56 B = Z[:13, 2:]
57
58 return R, G, B
59
60 fig = plt.figure(1)
61 ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
62
63 r, g, b = get_rgb()
64 kwargs = dict(origin="lower", interpolation="nearest")
65 ax.imshow_rgb(r, g, b, **kwargs)
66
67 ax.RGB.set_xlim(0., 9.5)
68 ax.RGB.set_ylim(0.9, 10.6)
69
70 plt.draw()
71 return plt.gcf()
72
73
74def create_figure():

Callers

nothing calls this directly

Calls 3

get_rgbFunction · 0.70
closeMethod · 0.45
drawMethod · 0.45

Tested by

no test coverage detected