Skip to content

Add examples for plotting lines  #493

Closed

Description

@seisman

Description of the desired feature

There are already have nice tutorials for plotting data points of various sizes and colors, but no examples for plotting lines.

It would be good to add some examples showing

  • how to plot lines
  • how to specify line attributes (pen thickness, color, and pen style)
  • plot lines with various colors as determined by a CPT file

Unfortunately, PyGMT currently can't handle multi-segments data as in GMT. To plot multiple lines, we still have to call fig.plot() multiple times.

Activity

  1. seisman commented on Oct 16, 2020

    @seisman
    MemberAuthor

    #604 (comment)

    Also, was just looking at the GMT.jl AGU gallery examples at https://www.generic-mapping-tools.org/GMT.jl/latest/gallery/tables/, looks like there's a lot of decorated arrows/curved line examples we can follow.

    image

  2. added this to the 0.3.0 milestone on Nov 22, 2020
  3. willschlitzer commented on Dec 11, 2020

    @willschlitzer
    Contributor

    I'll work on this.

  4. willschlitzer commented on Dec 16, 2020

    @willschlitzer
    Contributor

    I'm trying to figure out how to add a specific CPT, but I'm not getting it to plot on the actual line. I tried setting a specific CPT to cmap, and also tried adding "red,green" to add specific colors, but no luck.

  5. weiji14 commented on Dec 17, 2020

    @weiji14
    Member

    Yeah it's complicated, took me a while to figure it out recently too. Try this for inspiration:

    import pygmt
    import numpy as np
    
    fig = pygmt.Figure()
    fig.basemap(frame=["WSne", "af"], region=[20, 30, -10, 10])
    pygmt.makecpt(cmap="batlow", series=[0, 10, 1])
    x = np.arange(start=20, stop=30, step=0.2)
    for zvalue in range(0, 10):
        y = zvalue * np.sin(x)
        fig.plot(x=x, y=y, cmap=True, zvalue=zvalue, pen=f"thick,+z,-")
    
    fig.show()

    sine curve with different colors

  6. willschlitzer commented on Dec 17, 2020

    @willschlitzer
    Contributor

    @weiji14 Impressive find, but that seems like a big step up in complexity from the rest of the tutorial. I've been out of geoscience for 8+ years so I don't keep up with what people want in their plots, but this seems out of place for a basic "How to plot lines" tutorial. My opinion is something like this belongs in a gallery example.

  7. willschlitzer commented on Dec 22, 2020

    @willschlitzer
    Contributor

    @seisman Are you looking to have anything else added to these line plotting examples before closing the issue? As stated above, I think the custom CPT example provided by @weiji14 may be a bit advanced for a basic tutorial.

  8. seisman commented on Dec 22, 2020

    @seisman
    MemberAuthor

    @weiji14's example is pretty good and could be added to the gallery (https://www.pygmt.org/dev/gallery/index.html#lines).

  9. willschlitzer commented on Dec 28, 2020

    @willschlitzer
    Contributor

    @weiji14 Are you planning on adding your code to the gallery? I can submit a pull request for it if you're too busy.

  10. weiji14 commented on Dec 28, 2020

    @weiji14
    Member

    I literally came up with that in 5 minutes 😅, but yeah, feel free to adapt it into the gallery.

  11. willschlitzer commented on Dec 28, 2020

    @willschlitzer
    Contributor

    Sounds good! Didn't want to step on your toes; I'll type it up in the next day or so.

  12. willschlitzer commented on Jan 24, 2021

    @willschlitzer
    Contributor

    @seisman Are we good to close this issue now that #741 and #774 have been merged?

  13. seisman commented on Jan 24, 2021

    @seisman
    MemberAuthor

    @seisman Are we good to close this issue now that #741 and #774 have been merged?

    There are some lines/arrows we may want to add in the gallery. See #493 (comment)

  14. modified the milestones: 0.3.0, 0.4.0 on Feb 14, 2021
  15. pinned this issue on Mar 3, 2021
  16. core-man commented on Mar 15, 2021

    @core-man
    Member

    So we still want more line examples?

    • error bar? Do error bar belong to lines?
    • mat angles
    • bezier
    • decorated
    • decorated text

    Which one is on the top priority? @seisman

  17. seisman commented on Apr 2, 2021

    @seisman
    MemberAuthor

    I'm closing the issue, because I feel that the Figure.plot() method is becoming too complicated and may need some re-design. I prefer NOT to add more complicated (and less used) examples (e.g., decorated text) before we have some more discussions about Figure.plot().

  18. unpinned this issue on Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomershelp wantedHelping hands are appreciatedscipy-sprintThings to work on during the SciPy sprint!

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions