Created
July 31, 2023 13:47
-
-
Save story645/3bdcd47cfb68847c210ef63666a2d165 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib | |
import matplotlib.pyplot as plt | |
import matplotlib.patches as mpatches | |
matplotlib.rc('axes',edgecolor='gray', labelcolor='gray') | |
matplotlib.rc('xtick', labelcolor='gray', color='gray') | |
matplotlib.rc('ytick', labelcolor='gray', color='gray') | |
fig, axes = plt.subplots(nrows=7, ncols=2, | |
constrained_layout=True) | |
gridspec = axes[0,0].get_subplotspec().get_gridspec() | |
# clear first column to make axis | |
subfigs = [] | |
for i in range(7): | |
axes[i,0].remove() | |
subfigs.append(fig.add_subfigure(gridspec[i,0])) | |
axes[i,1].axis('off') | |
# full size | |
ax = subfigs[1].subplots() | |
#regular grid | |
ax = subfigs[2].subplots(2,3) | |
# complex grid | |
ax = subfigs[3].subplot_mosaic("AAB;CDB") | |
#inset | |
ax = subfigs[4].subplots() | |
ax_inset = ax.inset_axes([.4, .4, .3, .3]) | |
#twin | |
ax = subfigs[5].subplots() | |
axt = ax.twinx() | |
#manual | |
ax = subfigs[6].add_axes([.4, .4, .3, .3]) | |
for sub, label in zip(subfigs, ["", "Single Axes", | |
"Regular grid", | |
"Irregular grid", | |
"Inset Axes", | |
"Twin Axes", | |
"Manual Axes"]): | |
sub.suptitle(label, y=1, fontsize=12) | |
texts = [[["pyplot functions", "Figure/Axes Methods"]], | |
[["plt.subplots()", 'Figure.subplots'], | |
["plt.subplot()", "Figure.add_subplot()"]], | |
[["plt.subplots(n, m)", "Figure.subplots(n, m)"], | |
["plt.subplots(n, m, k)", "Figure.add_subplot(n,m,k)"]], | |
[["plt.subplot_mosaic()", "Figure.subplot_mosaic()"], | |
["plt.subplot2grid()", "GridSpec.subplots()"], | |
["plt.subplots(gridspec_kw)", "Figure.subplots(gridspec_kw)"], | |
["plt.subplot(subplotspec)", "Figure.subplot(subplotspec)"]], | |
[["", "Axes.inset_axes()"]], | |
[["plt.twinx()", "Axes.twinx()"], | |
["plt.twiny()", "Axes.twiny()"]], | |
[["plt.axes()", "Figure.add_axes()"]]] | |
for i in range(7): | |
tab = axes[i,1].table(texts[i], | |
cellColours=[['lightblue', 'lightgray'] | |
for i in range(len(texts[i]))]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment