Repository navigation
Closed
Labels
bugSomething isn't working
Description
Description of the problem
I added a colorbar to a plot3d and the default position is good, but when I added an "x" label with the frame parameter, the display image (in a Jupyter notebook) and the saved image has part of the text cut off.
Full code that generated the error
I think this will run without the input files.
import pygmt
fig2 = pygmt.Figure()
xsecProj = "M20c"
xsecProj = "U14/20c"
xsecReg = [-100.5, -99.1, 16.0, 17.5]
xsecReg3D = [-100.5, -99.1, 16.0, 17.5, 5.0,35.0]
xsecRegZ = [5.0,35.0]
xsecProjZ = "-15c"
xsec5View = [-160.,0.04,0.0]
#set Fault = 'Acapulco'
Fault="Acapulco"
slipD=Fault+".slipdir"
fault=Fault+".fault"
ellipses='ellipse_'+slipD
frameType=["WSZ", "zaf+lDepth (km)"]
pygmt.makecpt(cmap="hot", series=(0, 2, 0.1), reverse=True)
fig2.plot3d(
fault,
projection=xsecProj,
region=xsecReg3D,
zsize=xsecProjZ,
perspective=xsec5View,
pen="thin",
close=True, color="+z", cmap=True,
frame=frameType
)
fig2.plot3d(slipD, pen="thick,black",
projection=xsecProj,
region=xsecReg3D,
zsize=xsecProjZ,
perspective=xsec5View
)
fig2.plot3d(ellipses, pen="thin",
projection=xsecProj,
region=xsecReg3D,
zsize=xsecProjZ,
perspective=xsec5View
)
fig2.coast(
region=xsecReg3D,
perspective=xsec5View,
shorelines="1p,black",
)
positionCB="JMB+o2c/0c+w7c/0.5c+mc"
positionCB=None
fig2.colorbar(frame=["a0.5", "x+lSlip", "y+lm"], position=positionCB)
fig2.show()
fig2.savefig(Fault+"-slip-plot.png")Full error message
No error reported
See attached plot output.
System information
Please paste the output of python -c "import pygmt; pygmt.show_versions()":
PyGMT information:
version: v0.7.0
System information:
python: 3.9.13 | packaged by conda-forge | (main, May 27 2022, 17:00:52) [Clang 13.0.1 ]
executable: /Users/fielding/anaconda3/envs/pygmt/bin/python
machine: macOS-11.6.8-x86_64-i386-64bit
Dependency information:
numpy: 1.23.2
pandas: 1.4.3
xarray: 2022.6.0
netCDF4: 1.6.0
packaging: 21.3
geopandas: None
ghostscript: 9.54.0
gmt: 6.4.0
GMT library information:
binary dir: /Users/fielding/anaconda3/envs/pygmt/bin
cores: 16
grid layout: rows
library path: /Users/fielding/anaconda3/envs/pygmt/lib/libgmt.dylib
padding: 2
plugin dir: /Users/fielding/anaconda3/envs/pygmt/lib/gmt/plugins
share dir: /Users/fielding/anaconda3/envs/pygmt/share/gmt
version: 6.4.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't working

Activity
EJFielding commentedon Aug 27, 2022
The code above contains the workaround of specifying the color bar position, which works well. It would be nice if the default plot did not have the text cut off.
EJFielding commentedon Aug 27, 2022
I found that the plot is complete if I change the horizontal width of the projection to
15cinstead of20c. Does PyGMT have a page size that it is working with? Where is that defined? I did not see an explanation in the documentation about the effective page size.seisman commentedon Aug 28, 2022
No, PyGMT's paper size is the same as GMT, which is 11.6 meter by 11.6 meter, but the plotting origin is only 12.7 centimeter (or 2.54 centimeter in old GMT versions) away from the left-bottom corner of the paper. So the image will be cropped if the position of the colorbar is too low.
However, I can't reproduce your issue locally. Here is the image I have (without your slip data file):

Could you please check if you have a
gmt.conffile in your current directory or in your home directory?EJFielding commentedon Aug 28, 2022
Yes, I found that I did have a
gmt.conffile in the directory because I was running regular GMT there before. This is what it had:seisman commentedon Aug 28, 2022
PS_MEDIA in your gmt.conf file is likely the cause. What happens if you remove it?
EJFielding commentedon Aug 28, 2022
I removed the
gmt.confcompletely and I got the same result.seisman commentedon Aug 28, 2022
Do you mean you got the correct result or the incorrect result after removing
gmt.conf?EJFielding commentedon Aug 28, 2022
I got the same plot with the label clipped that I got before. When does PyGMT read the
gmt.conffile? Maybe it had already read the file before I deleted it. I saw an older discussion on the GMT forum about somebody having similar trouble with regular GMT in modern mode (https://forum.generic-mapping-tools.org/t/cropping-goes-through-titles-axis-labels/2933/8). I have been careless about removing thegmt.*files after running GMT and it seems that causes these problems. I ran my notebook in a new empty directory and it produced the expected results.EJFielding commentedon Aug 28, 2022
I will close this as not a PyGMT issue. It seems to be in the upstream GMT modern mode interaction with pre-existing
gmt.conffiles.