You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a lot of subplot / margin / zen mode stuff in the raw.plot matplotlib backend, too much to change safely in #12050. We should see if using layout='constrained' can get us similar (or better) results as it would probably simplify a lot of code, including a lot of subplots_adjust calls in tutorials and examples to make room for fig.suptitle calls that wouldn't otherwise be required.
The text was updated successfully, but these errors were encountered:
It doesn't seem doable using 'constrained', but here is a proof of concept that it's doable using Divider to conrol the sizes rather than doing subplots_adjust gymnastics:
Code
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import Divider, Size
h_normal = [Size.Fixed(0.25), Size.Scaled(1.), Size.Fixed(0.25)]
v_normal = [Size.Fixed(0.25), Size.Scaled(1.)]
h_zen = [Size.Fixed(0.25), Size.Scaled(1.), Size.Fixed(0)]
v_zen = [Size.Fixed(0), Size.Scaled(1.)]
zen = False
fig = plt.figure(layout=None)
div = Divider(fig, (0, 0, 1, 1), h_normal, v_normal)
ax_main = fig.add_axes(div.get_position(), axes_locator=div.new_locator(nx=1, ny=1))
ax_main.plot([1, 2, 3])
ax_help = fig.add_axes(div.get_position(), axes_locator=div.new_locator(nx=0, ny=0))
ax_help.text(0, 0, 'help')
ax_hscroll = fig.add_axes(div.get_position(), axes_locator=div.new_locator(nx=1, ny=0))
ax_hscroll.text(0, 0, "hscroll")
ax_vscroll = fig.add_axes(div.get_position(), axes_locator=div.new_locator(nx=2, ny=1))
ax_vscroll.text(0, 0, "vscroll", rotation=90)
def on_press(event):
global zen
zen = not zen
if zen:
h, v = h_zen, v_zen
visible = False
else:
h, v = h_normal, v_normal
visible = True
for ax in (ax_help, ax_hscroll, ax_vscroll):
ax.set_visible(visible)
div.set_vertical(v)
div.set_horizontal(h)
fig.canvas.draw_idle()
fig.canvas.mpl_connect('key_press_event', on_press)
I'll wait until #12050 is merged then work on this.
Looks like in the end it's quite buggy. You can get there, but there's no way to set padding in some cases. Then the clicks go through to the wrong axes (always to horizontal). So maybe we should try this someday... but the current solution is not so bad in the end!
There is a lot of subplot / margin / zen mode stuff in the
raw.plot
matplotlib backend, too much to change safely in #12050. We should see if usinglayout='constrained'
can get us similar (or better) results as it would probably simplify a lot of code, including a lot ofsubplots_adjust
calls in tutorials and examples to make room forfig.suptitle
calls that wouldn't otherwise be required.The text was updated successfully, but these errors were encountered: