Skip to content

Commit

Permalink
Examples: Make position codes consistent in comments (#3312)
Browse files Browse the repository at this point in the history
  • Loading branch information
yvonnefroehlich authored Jul 22, 2024
1 parent d8133b0 commit 7376e6e
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion examples/gallery/3d_plots/grdview_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def ackley(x, y):
# Add colorbar for gridded data
fig.colorbar(
frame="a2f1", # Set annotations in steps of two, tick marks in steps of one
position="JRM", # Place colorbar at position Right Middle
position="JMR", # Place colorbar in the Middle Right (MR) corner
)

fig.show()
3 changes: 2 additions & 1 deletion examples/gallery/basemaps/double_y_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class can control which axes should be plotted and optionally show annotations,
# Plot points for y2 data
fig.plot(x=x, y=y2, style="s0.28c", fill="red", label="y2")

# Create a legend in the top-left corner of the plot
# Create a legend in the Top Left (TL) corner of the plot with an
# offset of 0.1 centimeters
fig.legend(position="jTL+o0.1c", box=True)

fig.show()
11 changes: 5 additions & 6 deletions examples/gallery/embellishments/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
horizontal (**L**\ eft, **C**\ enter, **R**\ ight) alignment codes, e.g.
``position="jTR"`` for Top Right.
- **g**: using map coordinates, e.g. ``position="g170/-45"`` for longitude
170E, latitude 45S.
170° East, latitude 45° South.
- **x**: using paper coordinates, e.g. ``position="x5c/7c"`` for 5 cm, 7 cm
from anchor point.
- **n**: using normalized (0-1) coordinates, e.g. ``position="n0.4/0.8"``.
Note that the anchor point defaults to the bottom left (**BL**). Append ``+h``
to ``position`` to get a horizontal colorbar instead of a vertical one
(``+v``).
to ``position`` to get a horizontal colorbar instead of a vertical one (``+v``).
"""

# %%
Expand All @@ -34,7 +33,7 @@

# ============
# Create a colorbar designed for seismic tomography - roma
# Colorbar is placed at bottom center (BC) by default if no position is given
# Colorbar is placed at Bottom Center (BC) by default if no position is given
# Add quantity and unit as labels ("+l") to the x and y axes
# Add annotations ("+a") in steps of 0.5 and ticks ("+f") in steps of 0.1
fig.colorbar(cmap="roma", frame=["xa0.5f0.1+lVelocity", "y+lm/s"])
Expand Down Expand Up @@ -78,8 +77,8 @@
# Plot the colorbar
fig.colorbar(
cmap=True, # Use colormap set up above
# Colorbar placed inside the plot bounding box (j) at Bottom Left (BL),
# offset (+o) by 0.5 cm horizontally and 0.8 cm vertically from anchor
# Colorbar placed inside the plot bounding box (j) in the Bottom Left (BL) corner,
# with an offset (+o) by 0.5 cm horizontally and 0.8 cm vertically from the anchor
# point, and plotted horizontally (+h)
position="jBL+o0.5c/0.8c+h",
box=True,
Expand Down
6 changes: 3 additions & 3 deletions examples/gallery/embellishments/inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
# to "brown", the water to "lightblue", the shorelines width to "thin", and
# adding a frame
fig.coast(region="MG+r2", land="brown", water="lightblue", shorelines="thin", frame="a")
# Create an inset, setting the position to top left, the width to 3.5 cm, and
# the x- and y-offsets to 0.2 cm. The margin is set to 0, and the border is
# "gold" with a pen size of 1.5 points.
# Create an inset, placing it in the Top Left (TL) corner with a width of 3.5 cm and
# x- and y-offsets of 0.2 cm. The margin is set to 0, and the border is "gold" with a
# pen size of 1.5 points.
with fig.inset(position="jTL+w3.5c+o0.2c", margin=0, box="+p1.5p,gold"):
# Create a figure in the inset using coast. This example uses the azimuthal
# orthogonal projection centered at 47E, 20S. The land color is set to
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/embellishments/inset_rectangle_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
# figure
fig.coast(land="lightbrown", water="azure1", shorelines="2p", area_thresh=1000)

# Create an inset map, setting the position to bottom right, and the x- and
# y-offsets to 0.1 cm, respectively.
# Create an inset map, placing it in the Bottom Right (BR) corner with x- and
# y-offsets of 0.1 cm, respectively.
# The inset map contains the Japan main land. "U54S/3c" means UTM projection
# with a map width of 3 cm. The inset width and height are automatically
# calculated from the specified ``region`` and ``projection`` parameters.
Expand Down
8 changes: 4 additions & 4 deletions examples/gallery/embellishments/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
fig.plot(x=x, y=y2, style="c0.07c", fill="dodgerblue", label="cos(x)+1.1")

# Add a legend to the plot; place it within the plot bounding box with both
# reference ("J") and anchor ("+j") points being TopRight and with an offset
# of 0.2 centimeters in x and y directions; surround the legend with a box
# reference ("J") and anchor ("+j") points being the Top Right (TR) corner and an
# offset of 0.2 centimeters in x and y directions; surround the legend with a box
fig.legend(position="JTR+jTR+o0.2c", box=True)

# -----------------------------------------------------------------------------
Expand All @@ -55,8 +55,8 @@

fig.plot(x=x, y=y4, style="s0.07c", fill="orange", label="cos(x/2)-1.1")

# For a multi-column legend, users have to provide the width via "+w", here it
# is set to 6 centimeters; reference and anchor points are set to BottomRight
# For a multi-column legend, users have to provide the width via "+w", here it is
# set to 6 centimeters; reference and anchor points are the Bottom Right (BR) corner
fig.legend(position="JBR+jBR+o0.2c+w6c", box=True)

fig.show()
2 changes: 1 addition & 1 deletion examples/gallery/embellishments/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
fig = pygmt.Figure()
fig.basemap(region=[0, 10, 0, 2], projection="X6c", frame=True)

# add the GMT logo in the Top Right corner of the current map,
# Add the GMT logo in the Top Right (TR) corner of the current map,
# scaled up to be 3 cm wide and offset by 0.3 cm in x direction
# and 0.6 cm in y direction.
fig.logo(position="jTR+o0.3c/0.6c+w3c")
Expand Down
6 changes: 3 additions & 3 deletions examples/gallery/embellishments/timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
=========
The :meth:`pygmt.Figure.timestamp` method can draw the GMT timestamp logo on the plot.
The timestamp will always be shown relative to the bottom-left corner of the plot. By
default, the ``offset`` and ``justify`` parameters are set to ``("-54p", "-54p")``
(x, y directions) and ``"BL"`` (bottom-left), respectively.
The timestamp will always be shown relative to the Bottom Left (BL) corner of the plot.
By default, the ``offset`` and ``justify`` parameters are set to ``("-54p", "-54p")``
(x, y directions) and ``"BL"`` (Bottom Left), respectively.
"""

# %%
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/images/cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@

# Add a colorbar for the elevation
fig.colorbar(
# Place the colorbar inside the plot (lower-case "j") with justification
# Bottom Right and an offset ("+o") of 0.7 centimeters and
# Place the colorbar inside the plot (lower-case "j") in the Bottom
# Right (BR) corner with an offset ("+o") of 0.7 centimeters and
# 0.3 centimeters in x or y directions, respectively
# Move the x label above the horizontal colorbar ("+ml")
position="jBR+o0.7c/0.8c+h+w5c/0.3c+ml",
Expand Down
5 changes: 2 additions & 3 deletions examples/gallery/images/grdlandmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
Create 'wet-dry' mask grid
==========================
The :func:`pygmt.grdlandmask` function allows setting
all nodes on land or water to a specified value using
the ``maskvalues`` parameter.
The :func:`pygmt.grdlandmask` function allows setting all nodes on land
or water to a specified value using the ``maskvalues`` parameter.
"""

# %%
Expand Down
6 changes: 3 additions & 3 deletions examples/gallery/lines/wiggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
pen="1.0p",
# Draw a blue track with a width of 0.5 points
track="0.5p,blue",
# Plot a vertical scale bar at the right middle. The bar length is 100 in
# data (z) units. Set the z unit label to "nT".
position="jRM+w100+lnT",
# Plot a vertical scale bar at Middle Right (MR). The bar length (+w)
# is 100 in data (z) units. Set the z unit label (+l) to "nT".
position="jMR+w100+lnT",
)
fig.show()
6 changes: 3 additions & 3 deletions examples/gallery/maps/borders.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* **3** = Marine boundaries
* **a** = All boundaries (1-3)
For example, to draw national boundaries with a line thickness of 1p and black
line color use ``borders="1/1p,black"``. You can draw multiple boundaries by
passing in a list to ``borders``.
For example, to draw national boundaries with a line thickness of 1 point and
black line color use ``borders="1/1p,black"``. You can draw multiple boundaries
by passing in a list to ``borders``.
"""

# %%
Expand Down
12 changes: 6 additions & 6 deletions examples/tutorials/advanced/insets.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
# %%
# The :meth:`pygmt.Figure.inset` method uses a context manager, and is called
# using a ``with`` statement. The ``position`` parameter, including the inset
# width, is required to plot the inset. Using the **j** argument, the location
# of the inset is set to one of the 9 anchors (bottom-middle-top and
# left-center-right). In the example below, ``BL`` sets the inset to the bottom
# left. The ``box`` parameter can set the fill and border of the inset. In the
# example below, ``+pblack`` sets the border color to black and ``+glightred``
# sets the fill to light red.
# width, is required to plot the inset. Using the **j** modifier, the location
# of the inset is set to one of the 9 anchors (Top - Middle - Bottom and Left -
# Center - Right). In the example below, ``BL`` places the inset at the Bottom
# Left corner. The ``box`` parameter can set the fill and border of the inset.
# In the example below, ``+pblack`` sets the border color to black and
# ``+glightred`` sets the fill to light red.

fig = pygmt.Figure()
fig.coast(
Expand Down

0 comments on commit 7376e6e

Please sign in to comment.