Skip to content

Commit

Permalink
Use Axes instead of axes in galleries
Browse files Browse the repository at this point in the history
  • Loading branch information
timhoffm committed Oct 16, 2023
1 parent 6501209 commit a57683e
Show file tree
Hide file tree
Showing 116 changed files with 341 additions and 341 deletions.
2 changes: 1 addition & 1 deletion galleries/examples/animation/multiple_axes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
=======================
Multiple axes animation
Multiple Axes animation
=======================
This example showcases:
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/animation/random_walk.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def update_lines(num, walks, lines):
# Create lines initially without data
lines = [ax.plot([], [], [])[0] for _ in walks]

# Setting the axes properties
# Setting the Axes properties
ax.set(xlim3d=(0, 1), xlabel='X')
ax.set(ylim3d=(0, 1), ylabel='Y')
ax.set(zlim3d=(0, 1), zlabel='Z')
Expand Down
10 changes: 5 additions & 5 deletions galleries/examples/axes_grid1/demo_axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Axes divider
============
Axes divider to calculate location of axes and
create a divider for them using existing axes instances.
Axes divider to calculate location of Axes and
create a divider for them using existing Axes instances.
"""

import matplotlib.pyplot as plt
Expand All @@ -30,13 +30,13 @@ def demo_locatable_axes_hard(fig):

divider = SubplotDivider(fig, 2, 2, 2, aspect=True)

# axes for image
# Axes for image
ax = fig.add_subplot(axes_locator=divider.new_locator(nx=0, ny=0))
# axes for colorbar
# Axes for colorbar
ax_cb = fig.add_subplot(axes_locator=divider.new_locator(nx=2, ny=0))

divider.set_horizontal([
Size.AxesX(ax), # main axes
Size.AxesX(ax), # main Axes
Size.Fixed(0.05), # padding, 0.1 inch
Size.Fixed(0.2), # colorbar, 0.3 inch
])
Expand Down
12 changes: 6 additions & 6 deletions galleries/examples/axes_grid1/demo_axes_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Demo Axes Grid
==============
Grid of 2x2 images with a single colorbar or with one colorbar per axes.
Grid of 2x2 images with a single colorbar or with one colorbar per Axes.
"""

import matplotlib.pyplot as plt
Expand All @@ -17,13 +17,13 @@


# A grid of 2x2 images with 0.05 inch pad between images and only the
# lower-left axes is labeled.
# lower-left Axes is labeled.
grid = ImageGrid(
fig, 141, # similar to fig.add_subplot(141).
nrows_ncols=(2, 2), axes_pad=0.05, label_mode="1")
for ax in grid:
ax.imshow(Z, extent=extent)
# This only affects axes in first column and second row as share_all=False.
# This only affects Axes in first column and second row as share_all=False.
grid.axes_llc.set(xticks=[-2, 0, 2], yticks=[-2, 0, 2])


Expand All @@ -37,7 +37,7 @@
grid.cbar_axes[0].colorbar(im)
for cax in grid.cbar_axes:
cax.tick_params(labeltop=False)
# This affects all axes as share_all = True.
# This affects all Axes as share_all = True.
grid.axes_llc.set(xticks=[-2, 0, 2], yticks=[-2, 0, 2])


Expand All @@ -50,7 +50,7 @@
im = ax.imshow(Z, extent=extent)
cax.colorbar(im)
cax.tick_params(labeltop=False)
# This affects all axes as share_all = True.
# This affects all Axes as share_all = True.
grid.axes_llc.set(xticks=[-2, 0, 2], yticks=[-2, 0, 2])


Expand All @@ -65,7 +65,7 @@
im = ax.imshow(Z, extent=extent, vmin=vlim[0], vmax=vlim[1])
cb = cax.colorbar(im)
cb.set_ticks((vlim[0], vlim[1]))
# This affects all axes as share_all = True.
# This affects all Axes as share_all = True.
grid.axes_llc.set(xticks=[-2, 0, 2], yticks=[-2, 0, 2])


Expand Down
4 changes: 2 additions & 2 deletions galleries/examples/axes_grid1/demo_axes_grid2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def add_inner_title(ax, title, loc, **kwargs):
ZS = [Z[i::3, :] for i in range(3)]
extent = extent[0], extent[1]/3., extent[2], extent[3]

# *** Demo 1: colorbar at each axes ***
# *** Demo 1: colorbar at each Axes ***
grid = ImageGrid(
# 211 = at the position of fig.add_subplot(211)
fig, 211, nrows_ncols=(1, 3), axes_pad=0.05, label_mode="1", share_all=True,
Expand All @@ -60,7 +60,7 @@ def add_inner_title(ax, title, loc, **kwargs):
for ax, z in zip(grid2, ZS):
im = ax.imshow(z, clim=clim, origin="lower", extent=extent)

# With cbar_mode="single", cax attribute of all axes are identical.
# With cbar_mode="single", cax attribute of all Axes are identical.
ax.cax.colorbar(im)

for ax, im_title in zip(grid2, ["(a)", "(b)", "(c)"]):
Expand Down
4 changes: 2 additions & 2 deletions galleries/examples/axes_grid1/demo_axes_hbox_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Using an `.HBoxDivider` to arrange subplots.
Note that both axes' location are adjusted so that they have
Note that both Axes' location are adjusted so that they have
equal heights while maintaining their aspect ratios.
"""
Expand Down Expand Up @@ -36,7 +36,7 @@
# %%
# Using a `.VBoxDivider` to arrange subplots.
#
# Note that both axes' location are adjusted so that they have
# Note that both Axes' location are adjusted so that they have
# equal widths while maintaining their aspect ratios.

fig, (ax1, ax2) = plt.subplots(2, 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
===============================
Adding a colorbar to inset axes
Adding a colorbar to inset Axes
===============================
"""

Expand Down
12 changes: 6 additions & 6 deletions galleries/examples/axes_grid1/demo_colorbar_with_axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
Colorbar with AxesDivider
=========================
The `.axes_divider.make_axes_locatable` function takes an existing axes, adds
The `.axes_divider.make_axes_locatable` function takes an existing Axes, adds
it to a new `.AxesDivider` and returns the `.AxesDivider`. The `.append_axes`
method of the `.AxesDivider` can then be used to create a new axes on a given
side ("top", "right", "bottom", or "left") of the original axes. This example
uses `.append_axes` to add colorbars next to axes.
method of the `.AxesDivider` can then be used to create a new Axes on a given
side ("top", "right", "bottom", or "left") of the original Axes. This example
uses `.append_axes` to add colorbars next to Axes.
Users should consider simply passing the main axes to the *ax* keyword argument of
`~.Figure.colorbar` instead of creating a locatable axes manually like this.
Users should consider simply passing the main Axes to the *ax* keyword argument of
`~.Figure.colorbar` instead of creating a locatable Axes manually like this.
See :ref:`colorbar_placement`.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
This example shows how to control the position, height, and width of colorbars
using `~mpl_toolkits.axes_grid1.inset_locator.inset_axes`.
Inset axes placement is controlled as for legends: either by providing a *loc*
Inset Axes placement is controlled as for legends: either by providing a *loc*
option ("upper right", "best", ...), or by providing a locator with respect to
the parent bbox. Parameters such as *bbox_to_anchor* and *borderpad* likewise
work in the same way, and are also demonstrated here.
Expand Down
4 changes: 2 additions & 2 deletions galleries/examples/axes_grid1/demo_edge_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def demo_bottom_cbar(fig):
for cax in grid.cbar_axes:
cax.axis[cax.orientation].set_label("Bar")

# This affects all axes as share_all = True.
# This affects all Axes as share_all = True.
grid.axes_llc.set_xticks([-2, 0, 2])
grid.axes_llc.set_yticks([-2, 0, 2])

Expand Down Expand Up @@ -73,7 +73,7 @@ def demo_right_cbar(fig):
for cax in grid.cbar_axes:
cax.axis[cax.orientation].set_label('Foo')

# This affects all axes because we set share_all = True.
# This affects all Axes because we set share_all = True.
grid.axes_llc.set_xticks([-2, 0, 2])
grid.axes_llc.set_yticks([-2, 0, 2])

Expand Down
4 changes: 2 additions & 2 deletions galleries/examples/axes_grid1/demo_fixed_size_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

fig = plt.figure(figsize=(6, 6))

# The first items are for padding and the second items are for the axes.
# The first items are for padding and the second items are for the Axes.
# sizes are in inch.
h = [Size.Fixed(1.0), Size.Fixed(4.5)]
v = [Size.Fixed(0.7), Size.Fixed(5.)]
Expand All @@ -35,7 +35,7 @@
fig = plt.figure(figsize=(6, 6))

# The first & third items are for padding and the second items are for the
# axes. Sizes are in inches.
# Axes. Sizes are in inches.
h = [Size.Fixed(1.0), Size.Scaled(1.), Size.Fixed(.2)]
v = [Size.Fixed(0.7), Size.Scaled(1.), Size.Fixed(.5)]

Expand Down
22 changes: 11 additions & 11 deletions galleries/examples/axes_grid1/inset_locator_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# %%
# The `.inset_locator`'s `~.inset_locator.inset_axes` allows
# easily placing insets in the corners of the axes by specifying a width and
# easily placing insets in the corners of the Axes by specifying a width and
# height and optionally a location (loc) that accepts locations as codes,
# similar to `~matplotlib.axes.Axes.legend`.
# By default, the inset is offset by some points from the axes,
Expand All @@ -23,17 +23,17 @@
# at the default upper right location
axins = inset_axes(ax, width=1.3, height=0.9)

# Create inset of width 30% and height 40% of the parent axes' bounding box
# Create inset of width 30% and height 40% of the parent Axes' bounding box
# at the lower left corner (loc=3)
axins2 = inset_axes(ax, width="30%", height="40%", loc=3)

# Create inset of mixed specifications in the second subplot;
# width is 30% of parent axes' bounding box and
# width is 30% of parent Axes' bounding box and
# height is 1 inch at the upper left corner (loc=2)
axins3 = inset_axes(ax2, width="30%", height=1., loc=2)

# Create an inset in the lower right corner (loc=4) with borderpad=1, i.e.
# 10 points padding (as 10pt is the default fontsize) to the parent axes
# 10 points padding (as 10pt is the default fontsize) to the parent Axes
axins4 = inset_axes(ax2, width="20%", height="20%", loc=4, borderpad=1)

# Turn ticklabels of insets off
Expand All @@ -54,9 +54,9 @@
fig = plt.figure(figsize=[5.5, 2.8])
ax = fig.add_subplot(121)

# We use the axes transform as bbox_transform. Therefore, the bounding box
# We use the Axes transform as bbox_transform. Therefore, the bounding box
# needs to be specified in axes coordinates ((0, 0) is the lower left corner
# of the axes, (1, 1) is the upper right corner).
# of the Axes, (1, 1) is the upper right corner).
# The bounding box (.2, .4, .6, .5) starts at (.2, .4) and ranges to (.8, .9)
# in those coordinates.
# Inside this bounding box an inset of half the bounding box' width and
Expand All @@ -78,7 +78,7 @@


# Note how the two following insets are created at the same positions, one by
# use of the default parent axes' bbox and the other via a bbox in axes
# use of the default parent Axes' bbox and the other via a bbox in Axes
# coordinates and the respective transform.
ax2 = fig.add_subplot(222)
axins2 = inset_axes(ax2, width="30%", height="50%")
Expand All @@ -101,16 +101,16 @@


# %%
# In the above the axes transform together with 4-tuple bounding boxes has been
# used as it mostly is useful to specify an inset relative to the axes it is
# In the above the Axes transform together with 4-tuple bounding boxes has been
# used as it mostly is useful to specify an inset relative to the Axes it is
# an inset to. However, other use cases are equally possible. The following
# example examines some of those.
#

fig = plt.figure(figsize=[5.5, 2.8])
ax = fig.add_subplot(131)

# Create an inset outside the axes
# Create an inset outside the Axes
axins = inset_axes(ax, width="100%", height="100%",
bbox_to_anchor=(1.05, .6, .5, .4),
bbox_transform=ax.transAxes, loc=2, borderpad=0)
Expand All @@ -134,7 +134,7 @@
bbox_transform=ax2.transData, loc=2, borderpad=0)

# Create an inset horizontally centered in figure coordinates and vertically
# bound to line up with the axes.
# bound to line up with the Axes.
from matplotlib.transforms import blended_transform_factory # noqa

transform = blended_transform_factory(fig.transFigure, ax2.transAxes)
Expand Down
8 changes: 4 additions & 4 deletions galleries/examples/axes_grid1/inset_locator_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
ax.set_aspect(1)

axins = zoomed_inset_axes(ax, zoom=0.5, loc='upper right')
# fix the number of ticks on the inset axes
# fix the number of ticks on the inset Axes
axins.yaxis.get_major_locator().set_params(nbins=7)
axins.xaxis.get_major_locator().set_params(nbins=7)
axins.tick_params(labelleft=False, labelbottom=False)
Expand Down Expand Up @@ -61,13 +61,13 @@ def add_sizebar(ax, size):
x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9
axins2.set_xlim(x1, x2)
axins2.set_ylim(y1, y2)
# fix the number of ticks on the inset axes
# fix the number of ticks on the inset Axes
axins2.yaxis.get_major_locator().set_params(nbins=7)
axins2.xaxis.get_major_locator().set_params(nbins=7)
axins2.tick_params(labelleft=False, labelbottom=False)

# draw a bbox of the region of the inset axes in the parent axes and
# connecting lines between the bbox and the inset axes area
# draw a bbox of the region of the inset Axes in the parent Axes and
# connecting lines between the bbox and the inset Axes area
mark_inset(ax2, axins2, loc1=2, loc2=4, fc="none", ec="0.5")

plt.show()
10 changes: 5 additions & 5 deletions galleries/examples/axes_grid1/scatter_hist_locatable_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
Show the marginal distributions of a scatter plot as histograms at the sides of
the plot.
For a nice alignment of the main axes with the marginals, the axes positions
For a nice alignment of the main Axes with the marginals, the Axes positions
are defined by a ``Divider``, produced via `.make_axes_locatable`. Note that
the ``Divider`` API allows setting axes sizes and pads in inches, which is its
the ``Divider`` API allows setting Axes sizes and pads in inches, which is its
main feature.
If one wants to set axes sizes and pads relative to the main Figure, see the
If one wants to set Axes sizes and pads relative to the main Figure, see the
:doc:`/gallery/lines_bars_and_markers/scatter_hist` example.
"""

Expand All @@ -33,10 +33,10 @@
# the scatter plot:
ax.scatter(x, y)

# Set aspect of the main axes.
# Set aspect of the main Axes.
ax.set_aspect(1.)

# create new axes on the right and on the top of the current axes
# create new Axes on the right and on the top of the current Axes
divider = make_axes_locatable(ax)
# below height and pad are in inches
ax_histx = divider.append_axes("top", 1.2, pad=0.1, sharex=ax)
Expand Down
6 changes: 3 additions & 3 deletions galleries/examples/axes_grid1/simple_axes_divider1.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def label_axes(ax, text):


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

fig = plt.figure(figsize=(6, 6))
fig.suptitle("Fixed axes sizes, fixed paddings")
Expand All @@ -30,7 +30,7 @@ def label_axes(ax, text):
vert = [Size.Fixed(1.5), Size.Fixed(.5), Size.Fixed(1.)]

rect = (0.1, 0.1, 0.8, 0.8)
# Divide the axes rectangle into a grid with sizes specified by horiz * vert.
# Divide the Axes rectangle into a grid with sizes specified by horiz * vert.
div = Divider(fig, rect, horiz, vert, aspect=False)

# The rect parameter will actually be ignored and overridden by axes_locator.
Expand All @@ -53,7 +53,7 @@ def label_axes(ax, text):
vert = [Size.Scaled(1.), Size.Fixed(.5), Size.Scaled(1.5)]

rect = (0.1, 0.1, 0.8, 0.8)
# Divide the axes rectangle into a grid with sizes specified by horiz * vert.
# Divide the Axes rectangle into a grid with sizes specified by horiz * vert.
div = Divider(fig, rect, horiz, vert, aspect=False)

# The rect parameter will actually be ignored and overridden by axes_locator.
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/axes_grid1/simple_axes_divider3.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
horiz = [Size.AxesX(ax[0]), Size.Fixed(.5), Size.AxesX(ax[1])]
vert = [Size.AxesY(ax[0]), Size.Fixed(.5), Size.AxesY(ax[2])]

# divide the axes rectangle into grid whose size is specified by horiz * vert
# divide the Axes rectangle into grid whose size is specified by horiz * vert
divider = Divider(fig, rect, horiz, vert, aspect=False)


Expand Down
4 changes: 2 additions & 2 deletions galleries/examples/axes_grid1/simple_axesgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

fig = plt.figure(figsize=(4., 4.))
grid = ImageGrid(fig, 111, # similar to subplot(111)
nrows_ncols=(2, 2), # creates 2x2 grid of axes
axes_pad=0.1, # pad between axes in inch.
nrows_ncols=(2, 2), # creates 2x2 grid of Axes
axes_pad=0.1, # pad between Axes in inch.
)

for ax, im in zip(grid, [im1, im2, im3, im4]):
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/axisartist/demo_axisline_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
This example shows some configurations for axis style.
Note: The `mpl_toolkits.axisartist` axes classes may be confusing for new
Note: The `mpl_toolkits.axisartist` Axes classes may be confusing for new
users. If the only aim is to obtain arrow heads at the ends of the axes,
rather check out the :doc:`/gallery/spines/centered_spines_with_arrows`
example.
Expand Down
Loading

0 comments on commit a57683e

Please sign in to comment.