Skip to content

Instantly share code, notes, and snippets.

@cvanelteren
Created June 10, 2021 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cvanelteren/c975fc161b8e203b565921ceac39760e to your computer and use it in GitHub Desktop.
Save cvanelteren/c975fc161b8e203b565921ceac39760e to your computer and use it in GitHub Desktop.
Example of mosaic_layouts
import matplotlib.pyplot as plt, cmasher as cmr
import numpy as np
layout = np.zeros((10, 10), dtype = object)
layout[-1, :] = np.arange(1, 11)
layout[:, -1] = np.arange(20, 30)
fig = plt.figure(constrained_layout = 1)
axs = fig.subplot_mosaic(layout)
ax = axs.get(-1)
from matplotlib.patches import ConnectionPatch
for i in layout.flat:
axi = axs.get(i)
# arrow stuff
# xyA = (0, .5)
# xyB = xy[i]
# p = ConnectionPatch(xyA = xyA, xyB = xyB, coordsA = axi.transAxes,
# coordsB = ax.transData,
# color = 'gray',
# arrowstyle= '->',
# shrinkB = 2,
# mutation_scale= 10,
# linewidth = 2,
# connectionstyle= 'arc3, rad=.1')
#fig.add_artist(p)
fig.subplots_adjust(hspace = .2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment