Hii, I am using PyGmt for plotting a seismic station map.By default the tick marks are coming outside the plot. I want the tick marks to be inside the plot.I hope experts will suggest a solution for the same.Thanks.
Hello @seis,
you can adjust the frame of your plot or map be setting MAP_FRAME_TYPE
using pygmt.config
.
There are 5 options: fancy
, fancy+
, plain
, graph
, and inside
. Maybe you find the following PyGMT tutorial helpful:
https://www.pygmt.org/latest/tutorials/advanced/configuration.html#sphx-glr-tutorials-advanced-configuration-py
Here, you probably want to use MAP_FRAME_TYPE="inside"
. However, I am currently unsure whether you only want the ticks itself to be inside the plot or also the annotations.
Please see the example below for orientation:
import pygmt
fig = pygmt.Figure()
pygmt.config(
MAP_FRAME_TYPE="inside",
)
fig.basemap(
region=[6, 12, 42, 47],
projection="M10c",
frame="af",
)
fig.show()
Output figure:
I need only ticks mark inside the plot not the values
If you only want the ticks itself in side the plot, I do not know a real solution, except the “trick” using a negative value for MAP TICK LENGTH
. Maybe someone else can help out.
import pygmt
fig = pygmt.Figure()
pygmt.config(
MAP_TICK_LENGTH="-5p", # negative
)
fig.basemap(
region=[6, 12, 42, 47],
projection="M10c",
frame="af",
)
fig.show()
I have just seen that there is currently a similar issue on GitHub: how to plot tick marks inside the plot · Issue #2150 · GenericMappingTools/pygmt (github.com)
Yes, its mine only…however I am facing problem.
I want to switch on ticks and its values on both the axes. I tried WSEN but on both axes ticks are not on.
Please suggest a solution.
Thanks
I see, no worries .
Do you try to accomplish this:
import pygmt
fig = pygmt.Figure()
pygmt.config(
MAP_TICK_LENGTH="-5p",
)
fig.basemap(
region=[6, 12, 42, 47],
projection="M10c",
frame=["WSEN", "af"], # pass a list
)
fig.show()
With this code I get the following figure:
Thanks @yvonnefroehlich. I want to reduce the frame width and font size of the tick values also. While I am doing the MAP_FRAME_WIDTH=0.5 its not reducing, Are there any other solution for the same.
You have to set the argument into quotation marks (and to give an unit). To adjust the front size you can use FONT_ANNOT_PRIMARY
. Btw: you finde an overview of all GMT or PyGMT default parameters here: gmt.conf — GMT 6.5.0 documentation (generic-mapping-tools.org).
Here is an example:
import pygmt
fig = pygmt.Figure()
pygmt.config(
# https://docs.generic-mapping-tools.org/dev/gmt.conf.html#map-parameters
MAP_TICK_LENGTH="-5p",
MAP_FRAME_WIDTH="1p",
# https://docs.generic-mapping-tools.org/dev/gmt.conf.html#font-parameters
FONT_ANNOT_PRIMARY="6p",
)
fig.basemap(
region=[6, 12, 42, 47],
projection="M10c",
frame=["WSEN", "af"],
)
fig.show()
Thanks @yvonnefroehlich for your suggestions.
Pleased I could help out!