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 an example for double Y-axis graph #1009

Closed
seisman opened this issue Mar 5, 2021 · 1 comment · Fixed by #1019
Closed

Add an example for double Y-axis graph #1009

seisman opened this issue Mar 5, 2021 · 1 comment · Fixed by #1019
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Milestone

Comments

@seisman
Copy link
Member

seisman commented Mar 5, 2021

image

Figure from https://www.originlab.com/doc/Origin-Help/Double-Y-Graph.

This kind of base maps are commonly seen. In GMT or PyGMT, we need to make two base maps (with same x limits but different Y limits) and plot data points separately.

This is a good gallery example, but I'm not sure which category it falls in.

@seisman seisman added good first issue Good for newcomers documentation Improvements or additions to documentation labels Mar 5, 2021
@core-man
Copy link
Member

core-man commented Mar 7, 2021

A quick demo:

import pygmt
import numpy as np

x = np.linspace(1.0, 9.0, num=9)
y = x
z = x**2 + 110

fig = pygmt.Figure()
fig.plot(
    region=[0, 10, 0, 10],
    projection="X5c/5c",
    frame=["WS", "af", "x+lX", "y+lY1"],
    x=x,
    y=y,
    style="c0.2c",
    color="blue",
    label="Y1",
)
fig.plot(
    region=[0, 10, 0, 200],
    frame=["Et", "af", "y+lY2"],
    x=x,
    y=z,
    style="s0.3c",
    color="red",
    label="Y2",
)
fig.legend(position="JTL+jTL+o0.2c", box=True)
fig.show()

Screenshot from 2021-03-07 21-57-45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants