-
Notifications
You must be signed in to change notification settings - Fork 224
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 plotting lines tutorial #741
Add plotting lines tutorial #741
Conversation
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Would a section on plotting points belong in this tutorial, or should that be a separate tutorial? |
There is already a tutorial about plotting points (https://www.pygmt.org/dev/tutorials/plot.html). |
Must have missed that; my apologies! |
examples/tutorials/line-plot.py
Outdated
# In the example below, the pen width is set to ``"5p"``, and with *black* as the | ||
# default color and *solid* as the default style. | ||
|
||
fig = pygmt.Figure() | ||
fig.plot( | ||
region=[0, 10, 0, 10], | ||
projection="X25c/20c", | ||
frame="a", | ||
x=[1, 8], | ||
y=[3, 9], | ||
pen="5p", | ||
) | ||
fig.show() | ||
|
||
######################################################################################## | ||
# The line color can be set and is added after the line width to the ``pen`` argument. | ||
# In the example below, the line color is set to "red". | ||
|
||
fig = pygmt.Figure() | ||
fig.plot( | ||
region=[0, 10, 0, 10], | ||
projection="X25c/20c", | ||
frame="a", | ||
x=[1, 8], | ||
y=[3, 9], | ||
pen="5p,red", | ||
) | ||
fig.show() | ||
|
||
######################################################################################## | ||
# The line style can be set and is added after the line width or color to the | ||
# ``pen`` argument. In the example below, the line color is set to *dot dot dash*, and | ||
# the default color *black* is used. | ||
|
||
fig = pygmt.Figure() | ||
fig.plot( | ||
region=[0, 10, 0, 10], | ||
projection="X25c/20c", | ||
frame="a", | ||
x=[1, 8], | ||
y=[3, 9], | ||
pen="5p,..-", | ||
) | ||
fig.show() | ||
|
||
######################################################################################## | ||
# The line width, color, and style can all be set in the same ``pen`` argument. In the | ||
# example below, the line width is set to *7p*, the color is set to *green*, and the | ||
# line style is *dash dot dash*. | ||
|
||
fig = pygmt.Figure() | ||
fig.plot( | ||
region=[0, 10, 0, 10], | ||
projection="X25c/20c", | ||
frame="a", | ||
x=[1, 8], | ||
y=[3, 9], | ||
pen="7p,green,-.-", | ||
) | ||
fig.show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking whether it's better to merge these 4 figures into a single figure, i.e., showing 4 lines with different line properties. It would save much space and also easier for people to compare the different pen settings.
We also have a gallery example for different line styles. I think you can add a link to that example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a conscious choice on my part, since the gallery already shows the different pen settings side by side. My thought process is that the tutorial instead takes the user through the steps of plotting a line, and shows how they can set one or more properties.
I'm happy to change it if you think its the smarter move, but I do like the way it's currently displayed.
Also, is there a good way to link to other PyGMT pages similar to using gmt-docs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. let's keep it this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is there a good way to link to other PyGMT pages similar to using gmt-docs?
You can use to link to that file:
:doc:`/gallery/line/linestyles`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I wasn't having any luck with trying variations of pygmt-docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html
You may read this if you want to know more about cross-references in ReST language.
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Adding a tutorial to show how to plot lines, as discussed in #493.