Anyone know how to draw a border around an individual subplot within a figure in matplotlib? I’m using pyplot.
eg:
import matplotlib.pyplot as plt
f = plt.figure()
ax1 = f.add_subplot(211)
ax2 = f.add_subplot(212)
# ax1.set_edgecolor('black')
..but Axes objects have no ‘edgecolor’, and I can’t seem to find a way to outline the plot from the figure level either.
I’m actually wrapping mpl code and adding a wx UI with controls that I would like to have context depending on which subplot is selected. i.e. User clicks on subplot within figure canvas — subplot is ‘selected’ (has an outline drawn around it, ideally sawtooth) — GUI updates to present controls to modify that specific subplot.
You essentially want to draw outside of the axes, right?
I adapted this from here. It would need clean up as I used some hard-coded “fudge-factors” in there.
Produces: