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

Figures plotting only half in Jupyter #291

Closed
EJFielding opened this issue Mar 10, 2019 · 21 comments
Closed

Figures plotting only half in Jupyter #291

EJFielding opened this issue Mar 10, 2019 · 21 comments
Labels
bug Something isn't working

Comments

@EJFielding
Copy link

I managed to buiild GMT from source (kind of like the old days when editing the configuration file and building source was the only way). I installed pygmt and got it to import in my Jupyter notebook. When I try to make a simple plot like the "first-figure" example, it only plots the left half of the figure and chops off the top a little. This is the same for the Jupyter notebook and the saved png file. Here is the example saved:
central-america-shorelines

@welcome
Copy link

welcome bot commented Mar 10, 2019

👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.

@liamtoney
Copy link
Member

liamtoney commented Mar 10, 2019

Thanks for posting, @EJFielding. Could you please provide the Python code you used to generate the above plot? I'm wondering if this is a figure width / portrait mode issue.

Edit: Whoops, I see that you mentioned the code that you're using above. Try setting a smaller figure width for the projection flag and see what happens... maybe projection="M4i", for example.

@EJFielding
Copy link
Author

Thanks for the quick reply. Yes, if I set the projection="M4i" then I see more of the figure, but not quite all. I am a beginning Jupyter user, so I don't have any idea what controls the width of the figure. For some reason, I can only plot figures that are about 3 inches wide.

It is good that the saved file is the same, so "what you see is what you get".

@seisman
Copy link
Member

seisman commented Mar 10, 2019

it only plots the left half of the figure and chops off the top a little. This is the same for the Jupyter notebook and the saved png file.

@EJFielding Could you try following GMT commands in your terminal and check if the generated PNG file is correct?

gmt begin map png
gmt basemap -R-90/-70/0/20 -JM8i -B
gmt coast -W
gmt end

Could you also please provide your GMT version (gmt --version) and gs version (gs --version)?

@EJFielding
Copy link
Author

I ran those GMT commands in the shell command line and I get the complete map.

fielding% gmt --version 6.0.0_2f22074_2019.03.09
gs --version 9.26

@seisman
Copy link
Member

seisman commented Mar 10, 2019

Could you please paste the output of following Python codes?

import pygmt
pygmt.print_clib_info()

@EJFielding
Copy link
Author

From Jupyter notebook, I get this:

Loaded libgmt:
binary dir: /opt/local/Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS
cores: 8
grid layout: rows
library path: /Users/fielding/tools/gmt/lib/libgmt.dylib
padding: 2
plugin dir: /Users/fielding/tools/gmt/lib/gmt/plugins
share dir: /Users/fielding/tools/gmt/share
version: 6.0.0

@EJFielding
Copy link
Author

I use MacPorts to install Python 3.6, so I kept my pygmt installation in my home directory tree to avoid messing with the MacPorts files, in case that makes a difference.

@seisman
Copy link
Member

seisman commented Mar 10, 2019

It looks OK to me. I have no idea where the problem is. Let's wait for @leouieda.

@leouieda
Copy link
Member

@EJFielding this is interesting. From GenericMappingTools/gmt#497 it seems to be a problem with the plot units. Could you share your cmake config for building GMT?

@leouieda leouieda added the bug Something isn't working label Mar 12, 2019
@EJFielding
Copy link
Author

Sure, I attach my config file.

ConfigUser.cmake.txt

@leouieda
Copy link
Member

🤔 I don't see anything wrong with the setup. It doesn't seem to be a problem on the Python side. I can't reproduce the effect. Which version of ghostscript do you have?

@EJFielding
Copy link
Author

I have gs --version 9.26

@joa-quim
Copy link
Member

When you do

gmtdefaults -D | grep PROJ_LENGTH_UNIT
PROJ_LENGTH_UNIT               = cm

it prints cm or inch? (Because the GMT 497 issue seems to be related to the use of inches)

@EJFielding
Copy link
Author

I have this default when I do that on the command line:

PROJ_LENGTH_UNIT = cm

I am not sure how to check the defaults within the Jupyter notebook.

@leouieda
Copy link
Member

It should be the same since we're using the same GMT library that the command line program uses.

@leouieda
Copy link
Member

From the discussion in GenericMappingTools/gmt#497, do you have a gmt.conf file in the current directory? The new GMT modern mode sets the PS_MEDIA to a huge page and then crops the plot down when exporting it afterwards. If you're setting PS_MEDIA and forcing it to be letter or A4, then this would be a problem.

@EJFielding
Copy link
Author

Thanks! Yes, I have a gmt.conf in this directory because I was running GMT5. It has PS_MEDIA letter in it.

@EJFielding
Copy link
Author

I removed the gmt.conf file and tried the 'first-figure.py plot again and it shows the whole thing. Here is the saved PNG:
central-america-shorelines

@EJFielding
Copy link
Author

I think you can close this issue. Maybe it would help to put something in the documentation to remove any gmt.conf left over from previous GMT5 runs.

@seisman seisman closed this as completed Mar 15, 2019
@leouieda
Copy link
Member

Thanks, Eric! It's good to know. We're actually discussing a better solution that wouldn't require the user to take action at GenericMappingTools/gmt#497

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants