Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Improve labeling in simple_axes_divider1 example. #20072

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 1 commit into from
Apr 25, 2021
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
25 changes: 18 additions & 7 deletions 25 examples/axes_grid1/simple_axes_divider1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@
=====================
Simple Axes Divider 1
=====================

"""

from mpl_toolkits.axes_grid1 import Size, Divider
import matplotlib.pyplot as plt


def label_axes(ax, text):
"""Place a label at the center of an axes, and remove the axis ticks."""
ax.text(.5, .5, text, transform=ax.transAxes,
horizontalalignment="center", verticalalignment="center")
ax.tick_params(bottom=False, labelbottom=False,
left=False, labelleft=False)


##############################################################################
# Fixed axes sizes; fixed paddings.

fig = plt.figure(figsize=(6, 6))
fig.suptitle("Fixed axes sizes, fixed paddings")

# Sizes are in inches.
horiz = [Size.Fixed(1.), Size.Fixed(.5), Size.Fixed(1.5), Size.Fixed(.5)]
Expand All @@ -24,17 +32,19 @@

# The rect parameter will actually be ignored and overridden by axes_locator.
ax1 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=0, ny=0))
label_axes(ax1, "nx=0, ny=0")
ax2 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=0, ny=2))
label_axes(ax2, "nx=0, ny=2")
ax3 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=2, ny=2))
label_axes(ax3, "nx=2, ny=2")
ax4 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=2, nx1=4, ny=0))

for ax in fig.axes:
ax.tick_params(labelbottom=False, labelleft=False)
label_axes(ax4, "nx=2, nx1=4, ny=0")

##############################################################################
# Axes sizes that scale with the figure size; fixed paddings.

fig = plt.figure(figsize=(6, 6))
fig.suptitle("Scalable axes sizes, fixed paddings")

horiz = [Size.Scaled(1.5), Size.Fixed(.5), Size.Scaled(1.), Size.Scaled(.5)]
vert = [Size.Scaled(1.), Size.Fixed(.5), Size.Scaled(1.5)]
Expand All @@ -45,11 +55,12 @@

# The rect parameter will actually be ignored and overridden by axes_locator.
ax1 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=0, ny=0))
label_axes(ax1, "nx=0, ny=0")
ax2 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=0, ny=2))
label_axes(ax2, "nx=0, ny=2")
ax3 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=2, ny=2))
label_axes(ax3, "nx=2, ny=2")
ax4 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=2, nx1=4, ny=0))

for ax in fig.axes:
ax.tick_params(labelbottom=False, labelleft=False)
label_axes(ax4, "nx=2, nx1=4, ny=0")

plt.show()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.