Skip to content

[Easy task if you know some sphinx] Add example for setting map title #335

Closed

Description

@weiji14

Description of the problem

Even though it's in the title, our map 🗺️ tutorial for setting map frames, ticks, titles and labels doesn't actually teach us how to set a title!

Current title-less map

We'll need your help 👋 to add that to the example. You'll be working on the pygmt/examples/tutorial/frames.py file which you can edit here or in your Text Editor or Integrated Development Environment (IDE).

To do that, you'll need to know how to use the the frame (B) setting in the basemap function. Specifically, you might need to refer to the GMT docs on setting the B-option. This one line of code below (adapted from #325 (comment)) is part of what you need to do the trick:

fig.basemap(frame=["ag", "+tTitle"]

You can find out more about contributing in our CONTRIBUTING.md docs. Leave a comment below if you'd like to start working on this and feel free to ask for help! It's actually as much of a learning experience for us as it will be for you 😄

Stretch goals

In addition to setting a title, Find out how to set an x-axis label called "Longitude" and y-axis label called "Latitude"!

Activity

  1. added
    good first issue
    hacktoberfest
    on Oct 9, 2019
  2. removed
    hacktoberfest
    on Nov 6, 2019
  3. weiji14 commented on Nov 14, 2019

    @weiji14
    MemberAuthor

    @Jessie42 will be working on this!

  4. kmaterna commented on Apr 16, 2020

    @kmaterna
    Contributor

    I noticed the same thing. Putting title-setting in the docs would be super helpful.
    It's slightly tricky with escape-character-quotations... Not sure if you want to explain things like this in the tutorials, but you can set the title on the fly like this:

    # my_variable is a string (ex: "shear stress")
    title="+t\"Map of "+my_variable+" values\"";
    fig.basemap(frame=["ag", title];
    
  5. added
    documentation
    help wanted
    on Jun 1, 2020
  6. added
    scipy-sprint
    on Jul 6, 2020
  7. willschlitzer commented on Dec 7, 2020

    @willschlitzer
    Contributor

    I'll take on this issue.

  8. willschlitzer commented on Dec 8, 2020

    @willschlitzer
    Contributor

    @weiji14 I'm struggling with the stretch goals of adding the axis labels. I thought it would be the same as setting the labels on the color bars, and the arguments would be x+lLongitude and y+lLatitude but that is not plotting any axis labels. I can't find anything in the PyGMT or GMT docs for the solution; any idea?

  9. seisman commented on Dec 8, 2020

    @seisman
    Member

    the arguments would be x+lLongitude and y+lLatitude but that is not plotting any axis labels

    GMT doesn't allow adding labels to geographic maps. As for geographic maps, the X-axis is always longitude and the Y axis is always latitude.

  10. willschlitzer commented on Dec 8, 2020

    @willschlitzer
    Contributor

    Since the rest of the tutorial is for geographic maps, do you think it's better to use a non-geographic map for this last part or just not include axis labels in this tutorial?

  11. seisman commented on Dec 8, 2020

    @seisman
    Member

    I don't have a good idea for this. Perhaps it's better to show labels for non-geographic maps and also explain why it doesn't work for geographic maps.

  12. willschlitzer commented on Dec 8, 2020

    @willschlitzer
    Contributor

    That's a good idea; I'll add it tomorrow

  13. willschlitzer commented on Dec 9, 2020

    @willschlitzer
    Contributor

    Currently struggling with adding the labels. I'm using:
    fig.basemap(region=[0, 10, 0, 20], projection="X4i/3i", frame=["x+lx-axis", "y+ly-axis"])

    It is plotting the x-axis label on both the top and bottom and the y-axis label on the left and right side. Not seeing anything in the GMT docs to specify that it only print in one location; any ideas?

  14. weiji14 commented on Dec 9, 2020

    @weiji14
    MemberAuthor

    Try with frame=["WSne", "x+lx-axis", "y+ly-axis"].

  15. willschlitzer commented on Dec 9, 2020

    @willschlitzer
    Contributor

    It worked! Thanks

  16. willschlitzer commented on Dec 9, 2020

    @willschlitzer
    Contributor

    @weiji14 @seisman Would needing to add the "WSne" argument be best explained that, by default, all axes are designated as primary axes and "WSne" is needed to make only the left and bottom axes primary?

  17. seisman commented on Dec 11, 2020

    @seisman
    Member

    Closed by #720.

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

    documentationgood first issuehelp wantedscipy-sprint

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions