10000 Separate plots using #### in make_room_for_ylabel_using_axesgrid.py by ardieorden · Pull Request #15513 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Separate plots using #### in make_room_for_ylabel_using_axesgrid.py #15513

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

Merged
merged 3 commits into from
Dec 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 36 additions & 41 deletions examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,59 @@
===================================

"""

import matplotlib.pyplot as plt

from mpl_toolkits.axes_grid1 import make_axes_locatable
from mpl_toolkits.axes_grid1.axes_divider import make_axes_area_auto_adjustable


if __name__ == "__main__":

import matplotlib.pyplot as plt
plt.figure()
ax = plt.axes([0, 0, 1, 1])

def ex1():
plt.figure(1)
ax = plt.axes([0, 0, 1, 1])
#ax = plt.subplot(111)
ax.set_yticks([0.5])
ax.set_yticklabels(["very long label"])

ax.set_yticks([0.5])
ax.set_yticklabels(["very long label"])
make_axes_area_auto_adjustable(ax)

make_axes_area_auto_adjustable(ax)
###############################################################################

def ex2():

plt.figure(2)
ax1 = plt.axes([0, 0, 1, 0.5])
ax2 = plt.axes([0, 0.5, 1, 0.5])
plt.figure()
ax1 = plt.axes([0, 0, 1, 0.5])
ax2 = plt.axes([0, 0.5, 1, 0.5])

ax1.set_yticks([0.5])
ax1.set_yticklabels(["very long label"])
ax1.set_ylabel("Y label")
ax1.set_yticks([0.5])
ax1.set_yticklabels(["very long label"])
ax1.set_ylabel("Y label")

ax2.set_title("Title")
ax2.set_title("Title")

make_axes_area_auto_adjustable(ax1, pad=0.1, use_axes=[ax1, ax2])
make_axes_area_auto_adjustable(ax2, pad=0.1, use_axes=[ax1, ax2])
make_axes_area_auto_adjustable(ax1, pad=0.1, use_axes=[ax1, ax2])
make_axes_area_auto_adjustable(ax2, pad=0.1, use_axes=[ax1, ax2])

def ex3():
###############################################################################

fig = plt.figure(3)
ax1 = plt.axes([0, 0, 1, 1])
divider = make_axes_locatable(ax1)

ax2 = divider.new_horizontal("100%", pad=0.3, sharey=ax1)
ax2.tick_params(labelleft=False)
fig.add_axes(ax2)
fig = plt.figure()
ax1 = plt.axes([0, 0, 1, 1])
divider = make_axes_locatable(ax1)

divider.add_auto_adjustable_area(use_axes=[ax1], pad=0.1,
adjust_dirs=["left"])
divider.add_auto_adjustable_area(use_axes=[ax2], pad=0.1,
adjust_dirs=["right"])
divider.add_auto_adjustable_area(use_axes=[ax1, ax2], pad=0.1,
adjust_dirs=["top", "bottom"])
ax2 = divider.new_horizontal("100%", pad=0.3, sharey=ax1)
ax2.tick_params(labelleft=False)
fig.add_axes(ax2)

ax1.set_yticks([0.5])
ax1.set_yticklabels(["very long label"])
divider.add_auto_adjustable_area(use_axes=[ax1], pad=0.1,
adjust_dirs=["left"])
divider.add_auto_adjustable_area(use_axes=[ax2], pad=0.1,
adjust_dirs=["right"])
divider.add_auto_adjustable_area(use_axes=[ax1, ax2], pad=0.1,
adjust_dirs=["top", "bottom"])

ax2.set_title("Title")
ax2.set_xlabel("X - Label")
ax1.set_yticks([0.5])
ax1.set_yticklabels(["very long label"])

ex1()
ex2()
ex3()
ax2.set_title("Title")
ax2.set_xlabel("X - Label")

plt.show()
plt.show()
0