Skip to content
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

Add a gallery example for a double y-axes graph #1019

Merged
merged 26 commits into from
Mar 12, 2021
Merged
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cb61f7c
Add a double y-axes gallery
core-man Mar 8, 2021
bf67588
Fix
core-man Mar 8, 2021
e7fb8d4
Fix
core-man Mar 8, 2021
e61e266
Format
core-man Mar 8, 2021
65f418b
Re-format
core-man Mar 8, 2021
fb736e2
Apply suggestions from code review
core-man Mar 8, 2021
a5ff49e
Use X15c/15c
core-man Mar 9, 2021
39080f7
Use customed frames, annotations, marks and labels
core-man Mar 9, 2021
9c9ff98
Merge branch 'master' into double-yaxis
core-man Mar 9, 2021
95ab64d
Tiny fix
core-man Mar 10, 2021
d5ffc6b
Merge branch 'double-yaxis' of github.com:core-man/pygmt into double-…
core-man Mar 10, 2021
8839695
Merge branch 'master' into double-yaxis
core-man Mar 10, 2021
71c20c9
Merge branch 'master' into double-yaxis
core-man Mar 10, 2021
87cd1d9
Apply suggestions from code review
core-man Mar 10, 2021
efe2cc2
Apply suggestions from code review
core-man Mar 11, 2021
f054e48
Add a short description about how to plot double-y
core-man Mar 11, 2021
e83dfbc
Use underscore for .py file name
core-man Mar 11, 2021
cbc6566
Merge branch 'master' into double-yaxis
core-man Mar 12, 2021
29dfdaa
Move double_y_axes to basemaps category
core-man Mar 12, 2021
b58469b
Add basemaps to conf.py
core-man Mar 12, 2021
ff4fae3
Tiny update
core-man Mar 12, 2021
d0b7eb6
Merge branch 'master' into double-yaxis
core-man Mar 12, 2021
b735288
Merge branch 'master' into double-yaxis
seisman Mar 12, 2021
2372d4f
Apply suggestions from code review
core-man Mar 12, 2021
1f9a3b7
Use in instead of at before top-left
core-man Mar 12, 2021
c4bb24b
Apply suggestions from code review
core-man Mar 12, 2021
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
70 changes: 70 additions & 0 deletions examples/gallery/plot/double-y-axes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"""
Double Y-axes
-------------

The ``frame`` parameter of the plotting methods of the :class:`pygmt.Figure`
class can control which axes should be plotted and possibly show annotations
and tick marks. By default, all the 4 axes are plotted, along with annotations
and tick marks (denoted **W**, **S**, **E**, **N**). Lower cases (**w**, **s**,
**e**, **n**) can be used to denote to only plot the axes with tick marks. We
can also only plot the axes without annotations and tick marks using **l**
(left axis), **r** (right axis), **t** (top axis), **b** (bottom axis).
"""

import numpy as np
import pygmt

# Generate common x values and two kinds of y values
x = np.linspace(1.0, 9.0, num=9)
y1 = x
y2 = x ** 2 + 110

fig = pygmt.Figure()

# Plot y1
# The left (W) and bottom (S) axes are plotted with annotations and tick marks
fig.basemap(
region=[0, 10, 0, 10],
projection="X5c/5c",
frame=["WS", "xaf+lx", "yaf+ly1"],
)
# Plot the line for y1
fig.plot(
x=x,
y=y1,
pen="1p,blue",
)
# Plot points for y1
fig.plot(
x=x,
y=y1,
style="c0.2c",
color="blue",
label="y1",
)

# Plot y2
# The right axis (E) is plotted with annotations and tick marks
# The top axis (t) is plotting without annotations and tick marks
fig.basemap(
region=[0, 10, 100, 200],
frame=["Et", "yaf+ly2"],
)
# Plot the line for y2
fig.plot(
x=x,
y=y2,
pen="1p,red",
)
# Plot points for y2
fig.plot(
x=x,
y=y2,
style="s0.28c",
color="red",
label="y2",
)

fig.legend(position="JTL+jTL+o0.1c", box=True)

fig.show()