Skip to content
Draft
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion doc/techref/justification_codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ tags: [remove-input]
Script showing the justification codes used in GMT / PyGMT.
"""
import pygmt
from pygmt.params import Position

size = 5
x1 = [-size, 0, size, size, size, 0, -size, -size, 0]
Expand Down Expand Up @@ -105,7 +106,14 @@ Script showing justification codes for plot embellishments, e.g., a colorbar.
fig = pygmt.Figure()
fig.basemap(projection="X10c/2c", region=[-size, size, -size, size], frame=0)

fig.colorbar(cmap="SCM/buda", frame=0, position="jMC+w10c/2c+h")
fig.colorbar(
cmap="SCM/buda",
frame=0,
position="MC",
length=10,
width=2,
orientation="horizontal"
)

for code in codes:
fig.text(
Expand Down
10 changes: 5 additions & 5 deletions examples/gallery/3d_plots/grdview_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import numpy as np
import pygmt
import xarray as xr
from pygmt.params import Position


# Define an interesting function of two variables, see:
Expand Down Expand Up @@ -46,8 +47,7 @@ def ackley(x, y):
SCALE = 0.5 # in centimeters
fig.grdview(
data,
# Set annotations and gridlines in steps of five, and
# tick marks in steps of one
# Set annotations and gridlines in steps of five, and tick marks in steps of one
frame=["a5f1g5", "za5f1g5"],
projection=f"x{SCALE}c",
zscale=f"{SCALE}c",
Expand All @@ -57,10 +57,10 @@ def ackley(x, y):
shading="+a45",
)

# Add colorbar for gridded data
# Add colorbar for gridded data at the Middle Right corner.
fig.colorbar(
frame="a2f1", # Set annotations in steps of two, tick marks in steps of one
position="JMR", # Place colorbar in the Middle Right (MR) corner
frame="a2f1",
position=Position("MR", cstype="outside"),
)

fig.show()
8 changes: 5 additions & 3 deletions examples/gallery/basemaps/ternary.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

# %%
import pygmt
from pygmt.params import Position

fig = pygmt.Figure()

Expand All @@ -40,7 +41,8 @@
],
)

# Add a colorbar indicating the values given in the fourth column of
# the input dataset
fig.colorbar(position="JBC+o0c/1.5c", frame="x+lPermittivity")
# Add a colorbar indicating the values given in the fourth column of the input dataset
fig.colorbar(
position=Position("BC", cstype="outside", offset=(0, 1.5)), frame="x+lPermittivity"
)
fig.show()
14 changes: 9 additions & 5 deletions examples/gallery/images/cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# %%
import pygmt
from pygmt.params import Box
from pygmt.params import Box, Position

# Define region of study area
# lon_min, lon_max, lat_min, lat_max in degrees East and North
Expand All @@ -41,10 +41,14 @@

# Add a colorbar for the elevation
fig.colorbar(
# Place the colorbar inside the plot (lowercase "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",
# Place the colorbar inside the plot in the Bottom Right (BR) corner with an offset
# of 0.7 centimeters and 0.3 centimeters in x- or y-directions, respectively;
# move the x-label above the horizontal colorbar.
position=Position("BR", offset=(0.7, 0.8)),
length=5,
width=0.3,
orientation="horizontal",
move_text=["label"],
# Add a box around the colobar, filled in white and a 30 % transparency, with a
# 0.8-point thick, black, outline.
box=Box(pen="0.8p,black", fill="white@30"),
Expand Down
9 changes: 7 additions & 2 deletions examples/gallery/images/grdgradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# %%
import pygmt
from pygmt.params import Position

# Define region of interest around Yosemite valley
region = [-119.825, -119.4, 37.6, 37.825]
Expand All @@ -37,8 +38,12 @@
frame=["WSrt+tOriginal Data Elevation Model", "xa0.1", "ya0.1"],
cmap=True,
)

fig.colorbar(position="JML+o1.4c/0c+w7c/0.5c", frame=["xa1000f500+lElevation", "y+lm"])
fig.colorbar(
position=Position("ML", cstype="outside", offset=(1.4, 0)),
length=7,
width=0.5,
frame=["xa1000f500+lElevation", "y+lm"],
)

# --------------- plotting the hillshade map -----------

Expand Down
9 changes: 8 additions & 1 deletion examples/gallery/images/grdgradient_shading.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

# %%
import pygmt
from pygmt.params import Position

# Load the 3 arc-minutes global relief grid in the target area around Caucasus
grid = pygmt.datasets.load_earth_relief(resolution="03m", region=[35, 50, 35, 45])
Expand Down Expand Up @@ -59,6 +60,12 @@
panel=True,
)

fig.colorbar(position="JBC+w10c/0.25c+h", frame="xa2000f500+lElevation (m)")
fig.colorbar(
position=Position("BC", cstype="outside"),
length=10,
width=0.25,
orientation="horizontal",
frame="xa2000f500+lElevation (m)",
)

fig.show()
3 changes: 2 additions & 1 deletion examples/gallery/images/grdlandmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

# %%
import pygmt
from pygmt.params import Position

fig = pygmt.Figure()

Expand All @@ -33,6 +34,6 @@
pygmt.makecpt(cmap="SCM/batlow", series=(0, 1, 1), color_model="+cwater,land")

fig.grdimage(grid=grid, cmap=True)
fig.colorbar(position="JMR+o0.5c/0c+w8c")
fig.colorbar(position=Position("MR", cstype="outside", offset=(0.5, 0)), length=8)

fig.show()
29 changes: 25 additions & 4 deletions examples/tutorials/advanced/grid_equalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

# %%
import pygmt
from pygmt.params import Position

# %%
# Load sample data
Expand Down Expand Up @@ -56,7 +57,12 @@
histtype=1,
pen="1p,black",
)
fig.colorbar(position="JMR+o1.5c/0c+w3c/0.3c", frame=True)
fig.colorbar(
position=Position("MR", cstype="outside", offset=(1.5, 0)),
length=3,
width=0.3,
frame=True,
)
fig.show()


Expand Down Expand Up @@ -125,7 +131,12 @@
pen="1p,black",
center=True,
)
fig.colorbar(position="JMR+o1.5c/0c+w3c/0.3c", frame=True)
fig.colorbar(
position=Position("MR", cstype="outside", offset=(1.5, 0)),
length=3,
width=0.3,
frame=True,
)
fig.show()


Expand Down Expand Up @@ -174,7 +185,12 @@
histtype=1,
pen="1p,black",
)
fig.colorbar(position="JMR+o1.5c/0c+w3c/0.3c", frame=True)
fig.colorbar(
position=Position("MR", cstype="outside", offset=(1.5, 0)),
length=3,
width=0.3,
frame=True,
)
fig.show()


Expand Down Expand Up @@ -239,7 +255,12 @@
pen="1p,black",
center=True,
)
fig.colorbar(position="JMR+o1.5c/0c+w3c/0.3c", frame=True)
fig.colorbar(
position=Position("MR", cstype="outside", offset=(1.5, 0)),
length=3,
width=0.3,
frame=True,
)
fig.show()

# sphinx_gallery_thumbnail_number = 3
Loading