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

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

Closed
weiji14 opened this issue Oct 9, 2019 · 14 comments · Fixed by #720
Closed

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

weiji14 opened this issue Oct 9, 2019 · 14 comments · Fixed by #720
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Helping hands are appreciated scipy-sprint Things to work on during the SciPy sprint!

Comments

@weiji14
Copy link
Member

weiji14 commented Oct 9, 2019

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"!

@weiji14 weiji14 added good first issue Good for newcomers hacktoberfest Hacking away in the month of October labels Oct 9, 2019
@weiji14 weiji14 removed the hacktoberfest Hacking away in the month of October label Nov 6, 2019
@weiji14
Copy link
Member Author

weiji14 commented Nov 14, 2019

@Jessie42 will be working on this!

@weiji14
Copy link
Member Author

weiji14 commented Nov 14, 2019

@kmaterna
Copy link
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];

@seisman seisman added documentation Improvements or additions to documentation help wanted Helping hands are appreciated labels Jun 1, 2020
@liamtoney liamtoney added the scipy-sprint Things to work on during the SciPy sprint! label Jul 6, 2020
@willschlitzer
Copy link
Contributor

I'll take on this issue.

@willschlitzer
Copy link
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?

@seisman
Copy link
Member

seisman commented Dec 8, 2020

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.

@willschlitzer
Copy link
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?

@seisman
Copy link
Member

seisman commented Dec 8, 2020

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.

@willschlitzer
Copy link
Contributor

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

@willschlitzer
Copy link
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?

@weiji14
Copy link
Member Author

weiji14 commented Dec 9, 2020

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

@willschlitzer
Copy link
Contributor

It worked! Thanks

@willschlitzer
Copy link
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?

@seisman
Copy link
Member

seisman commented Dec 11, 2020

Closed by #720.

@seisman seisman closed this as completed Dec 11, 2020
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 help wanted Helping hands are appreciated scipy-sprint Things to work on during the SciPy sprint!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants