Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider new constrained_layout engine in Mpl #112

Open
jnothman opened this issue Jan 24, 2021 · 1 comment
Open

Consider new constrained_layout engine in Mpl #112

jnothman opened this issue Jan 24, 2021 · 1 comment

Comments

@jnothman
Copy link
Owner

No description provided.

@jnothman
Copy link
Owner Author

jnothman commented Jul 25, 2021

Towards this:

from matplotlib import pyplot as plt

gridspec_kw = {"height_ratios": [3, 8, 2], "width_ratios": [2, 8]}
fig = plt.figure()
fig.set_constrained_layout(True)

ax_arr = fig.subplots(3, 2, gridspec_kw=gridspec_kw)
fig.canvas.draw()  # constrained layout optimisation
totals_ax = ax_arr[2, 0]
matrix_ax = ax_arr[2, 1]
intersection_ax = ax_arr[1, 1]
for unused_ax in ax_arr[:-1, 0]:
    unused_ax.set_visible(False)

intersection_ax.set_yticks([0, 1])
intersection_ax.set_yticklabels(["Hello", "World!!!!!!!!"])


(x0, y0), _ = totals_ax.get_position().get_points()
_, (x1, y1) = matrix_ax.get_position().get_points()
shading_ax = fig.add_axes([x0, y0, x1 - x0, y1 - y0], sharey=totals_ax, in_layout=False, zorder=-1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant