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

Function AxesGrid

DemoPrograms/Demo_Matplotlib_Browser.py:783–825  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

781
782
783def AxesGrid():
784 import numpy as np
785 import matplotlib.pyplot as plt
786 from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
787
788 def get_demo_image():
789 # prepare image
790 delta = 0.5
791
792 extent = (-3, 4, -4, 3)
793 x = np.arange(-3.0, 4.001, delta)
794 y = np.arange(-4.0, 3.001, delta)
795 X, Y = np.meshgrid(x, y)
796 Z1 = np.exp(-X ** 2 - Y ** 2)
797 Z2 = np.exp(-(X - 1) ** 2 - (Y - 1) ** 2)
798 Z = (Z1 - Z2) * 2
799
800 return Z, extent
801
802 def get_rgb():
803 Z, extent = get_demo_image()
804
805 Z[Z < 0] = 0.
806 Z = Z / Z.max()
807
808 R = Z[:13, :13]
809 G = Z[2:, 2:]
810 B = Z[:13, 2:]
811
812 return R, G, B
813
814 fig = plt.figure(1)
815 ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
816
817 r, g, b = get_rgb()
818 kwargs = dict(origin="lower", interpolation="nearest")
819 ax.imshow_rgb(r, g, b, **kwargs)
820
821 ax.RGB.set_xlim(0., 9.5)
822 ax.RGB.set_ylim(0.9, 10.6)
823
824 plt.draw()
825 return plt.gcf()
826
827
828

Callers

nothing calls this directly

Calls 2

get_rgbFunction · 0.70
drawMethod · 0.45

Tested by

no test coverage detected