I have generated a grid of subplots using matplotlib. Every subplot has a different combination of values for the variables "A" and "B". They are arranged so that moving along the x axis of the grid the value for A increases, and similarly for y axis and B. I would like to add external axes that encompass the whole grid and visualize the increase of the two quantities. Here is a summarized version of the code I'm currently using:
#--OS
import sys,os
import copy
import glob
#--math and datasets
import numpy as np
import pandas as pd
#--matplotlib
%matplotlib inline
import matplotlib
from matplotlib.ticker import MultipleLocator
from mpl_toolkits.axes_grid1 import make_axes_locatable
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from matplotlib.lines import Line2D
from matplotlib import ticker
from matplotlib import cm
import colorcet as cc
import holoviews as hv
from colorcet.plotting import swatch, swatches
ABinBounds= pd.DataFrame.from_dict({'max' : [2.3713730200033902,3.1622776601683795,4.216965733794858,5.623415332340302,7.4989399250827455,
10.0,13.335216533675034,17.782800679308078, 23.713730200033908,31.622776601683796,100.0],
'min': [1.7782800679308082, 2.3713730200033902, 3.1622776601683795, 4.216965733794858, 5.623415332340302, 7.4989399250827455,
10.0, 13.335216533675034, 17.782800679308078, 23.713730200033908, 31.622776601683796] } )
BBinBounds = pd.DataFrame.from_dict({'max': [0.001, 0.00158489, 0.00251189, 0.00398107, 0.00630957, 0.01, 0.0158489,
0.025118900000000003, 0.0398107, 0.0630957, 0.1, 0.15848900000000002, 0.251189, 0.398107, 0.630957, 1.0],
'min': [0.000630957, 0.001, 0.00158489, 0.00251189, 0.00398107, 0.00630957, 0.01, 0.0158489, 0.025118900000000003,
0.0398107, 0.0630957, 0.1, 0.15848900000000002, 0.251189, 0.398107, 0.630957] })
cmaprai=cc.cm.rainbow
nQ = len(BBinBounds)
nx = len(ABinBounds)
fig, axs = plt.subplots(nQ-1,nx,figsize = (40*1.6,40), sharex=True,sharey=True )
for i in range(len(ABinBounds)):
for j in range(len(BBinBounds) - 1 ):
jp = -(j+1); ip = i
ax = axs[jp,ip] #axs[(nQ-1-1)-j,i]
ax.text(0.1,0.75, '<B> = {:.2e}'.format((BBinBounds['max'][j]-BBinBounds['min'][j])/2),transform=ax.transAxes,fontsize=32 )
ax.text(0.1,0.4, '<A> = {:.4f}'.format((ABinBounds['max'][i]-ABinBounds['min'][i])/2),transform=ax.transAxes,fontsize=32 )
fig.subplots_adjust(right=0.9)
cbar_ax = fig.add_axes([0.95, 0.15, 0.02, 0.4])
norm = matplotlib.colors.Normalize(vmin=0, vmax=1)
cb = fig.colorbar(matplotlib.cm.ScalarMappable(norm=norm, cmap=cmaprai),cax=cbar_ax)
cb.ax.tick_params(labelsize=25) # set your label size here
plt.subplots_adjust(wspace=0, hspace=0)
plt.show()
This produces the following image:
and I would like to modify it in a way that it looks like the following one (each interval on the y and x axis should correspond to one row or column of the subplot grid):
For now I've tried obtatining that using inset
but without much success.