Skip to content

Add a gallery example for Figure.legend with StringIO input #3444

Closed

Description

@seisman

We already use the auto-legend feature in some tutorials/gallery examples, but we don't have an example for how to manually specify the legend specification. This gallery example (https://www.pygmt.org/dev/gallery/embellishments/legend.html) provides a link to the GMT official documentation and mentions that Figure.legend can accept a legend specification file without details.

After #3438 is merged, it would be possible to store the legend specification in a StringIO object, so an example would be good.

I think we can add the GMT official example at https://docs.generic-mapping-tools.org/6.5/legend.html#examples as a PyGMT gallery example, similar to the test in #3438.

Activity

  1. added
    documentation
    help wanted
    on Sep 18, 2024
  2. yvonnefroehlich commented on Sep 20, 2024

    @yvonnefroehlich
    Member

    The StringIO input option is a nice addition to the legend method.

    Should such a gallery example also explain the (main) GMT legend codes (see https://docs.generic-mapping-tools.org/6.5/legend.html#legend-codes)? I feel, for the mentioned GMT example, some addional comments are needed, as understanding a GMT legend specification file requires some knowledge of the GMT syntax (: .

  3. seisman commented on Sep 21, 2024

    @seisman
    MemberAuthor

    perhaps we should have a tutorial for legend rather than a gallery example.

  4. yvonnefroehlich commented on Sep 21, 2024

    @yvonnefroehlich
    Member

    perhaps we should have a tutorial for legend rather than a gallery example.

    Hm, should such a tutorial focus on creating a legend manually (including the main GMT legend codes) or covering both auto-legends (including the main modifiers that can be appended to the label parameter to adjust the legend) and manual legends (stringIO input, GMT legend codes)? For the later case, would this mean that we remove the current legend example or include it in this new tutorial? Maybe it is still good to have a short example showing how to add a legend in principle.

  5. seisman commented on Sep 23, 2024

    @seisman
    MemberAuthor

    Should such a gallery example also explain the (main) GMT legend codes (see https://docs.generic-mapping-tools.org/6.5/legend.html#legend-codes)? I feel, for the mentioned GMT example, some addional comments are needed, as understanding a GMT legend specification file requires some knowledge of the GMT syntax (: .

    We should not explain too many details about the legend codes in either a gallery example or a tutorial. These details should be written in the API documentation of Figure.legend.

    Hm, should such a tutorial focus on creating a legend manually (including the main GMT legend codes) or covering both auto-legends (including the main modifiers that can be appended to the label parameter to adjust the legend) and manual legends (stringIO input, GMT legend codes)? For the later case, would this mean that we remove the current legend example or include it in this new tutorial? Maybe it is still good to have a short example showing how to add a legend in principle.

    I think we have both a tutorial and multiple gallery examples. The tutorial should include topics like:

    • how to use auto legend
    • how to add legend manually by giving a legend specification file or a StringIO object
    • how to specify the legend position on map
    • how to add the legend box

    The gallery example should show what Figure.legend can do (e.g., two columns legend with lines, symbols, texts, colorbar/scalebar). That's why I think the complicated example in #3438 is qualified as a good gallery example.

  6. added this to the 0.15.0 milestone on Feb 12, 2025
  7. removed
    help wanted
    on Feb 12, 2025
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

    documentation

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions