Repository navigation
Closed
Description
Currently, GMT provides 9 different embellishments
- Map scale by
basemap -Lorcoast -L - Directional rose by
basemap -Tdorcoast -Td - Magnetic rose by
basemap -Tmorcoast -Tm - Colorbar by
colorbar - Legend by
legend - Raster images by
image - GMT logo by
logo - Map inset by
inset - Vertical scale of wiggles in
wiggle
Refer to https://docs.generic-mapping-tools.org/6.5/reference/features.html#plot-embellishments for details.
These embellishments have different properties thus different option flags/modifiers, but they all share the same syntax for positioning, as shown below:
- GMT logo:
-D[g|j|J|n|x]refpoint[+hheight|+wwidth][+jjustify][+odx[/dy]]Figure.logo: Add parameters position/width/height to specify logo position and dimensions #4014 - Map inset:
-D[g|j|J|n|x]refpoint+wwidth[/height][+jjustify][+odx[/dy]]Figure.inset: Add parameters position/width/height to specify inset position and dimensions #4047 - Legend:
-D[g|j|J|n|x]refpoint+wwidth[/height][+jjustify][+lspacing][+odx[/dy]]Figure.legend: Add parameters position/width/height/line_spacing to specify legend position and properties #4046 - Vertical scale:
-D[g|j|J|n|x]refpoint+wlength[+jjustify][+al|r][+odx[/dy]][+l[label]]Figure.wiggle: Add parameters position/length/label/label_alignment for the scalebar position and properties #4049 - Raster image:
-D[g|j|J|n|x]refpoint+rdpi[c]+w[-]width[/height][+jjustify][+nnx[/ny] ][+odx[/dy]]Figure.image: Add parameters position/width/height/dpi/replicate to control image position and properties #4045 - Map scale:
-L[g|j|J|n|x]refpoint+wlength[e|f|k|M|n|u][+aalign][+c[[slon/]slat]][+f][+jjustify][+l[label]][+odx[/dy]][+u][+v]Add Figure.scalebar to plot a scale bar on maps #4015 - Directional rose:
-Td[g|j|J|n|x]refpoint[+f|F[level]][+jjustify][+l[w,e,s,n]][+odx[/dy]][+wwidth]Add Figure.directional_rose to plot a directional rose on map #4025 - Magnetic rose:
-Tm[g|j|J|n|x]refpoint[+ddec[/dlabel]]][+ipen][+jjustify][+l[w,e,s,n]][+ppen][+tints][+odx[/dy]][+wwidth]Add Figure.magnetic_rose to plot a magnetic rose on map #4051 - Colorbar:
-D[g|j|J|n|x]refpoint[+wlength[/width]][+e[b|f][length]][+h|v][+jjustify][+m[a|c|l|u]][+n[txt]][+odx[/dy]][+r]Figure.colorbar: Add position/length/width and more parameters to specify colorbar position and properties #4048
The common syntax is
[g|j|J|n|x]refpoint[+jjustify][+odx[/dy]
g|j|J|n|xspecify the coordinate system- refpoint specifies the reference point
+jspecifies the anchor on the embellishment+oset the extra offset of the anchor.
In PR #4014, I propose four parameters: position_type/position/anchor/anchor_offset for such syntax. Since the four parameters will be used in several wrappers, discussions are necessary.
Reacted by Yvonne Fröhlich
Metadata
Metadata
Assignees
Labels
featureBrand new feature
Type
Projects
- StatusShow more project fieldsDone
Activity
seisman commentedon Nov 10, 2025
@GenericMappingTools/pygmt-maintainers Any comments before I continue?
seisman commentedon Nov 16, 2025
I was reading #1082 (comment), and I feel a
Positionclass is not a bad idea, considering that thePositionclass will be used in 9 wrappers and the class docstring is also the best place to explain how the positioning works (supersedes #4052).The
Positionclass can be used like this:seisman commentedon Nov 23, 2025
Ping @GenericMappingTools/pygmt-maintainers to decide if we want to implement it as multiple parameters or a class, i.e., #4014 vs #4212.
I prefer the
Positionclass in #4212.yvonnefroehlich commentedon Nov 24, 2025
I also prefer to have a
Positionclass.[-]Consistent parameters for GMT embellishment placement[/-][+]Add the Position class for GMT embellishment placement[/+]seisman commentedon Dec 15, 2025
As mentioned above, these methods share the same positioning syntax,
[g|j|J|n|x]refpoint[+jjustify][+odx[/dy]], for placing embellishments. We have introduced thePositionclass to control their placement; however, the requirement and behavior of thepositionparameter are still inconsistent across methods.Here is a summary of the default behaviors in GMT:
logox1i/0(but source codes saysx0/0)]2i]imagex0/0with some x-offset]colorbarJBC, with some y-offset]scalebarx0/0]directional_rosex0/0]magnetic_rosex0/0]wigglex0/0]insetlegendJTR+jTR+o0.2cI think there is potential bugs for the default positioning of
logoandimage. For example,gmt logoandgmt logo -D+w2iproduce different outputs. I feel it makes sense to let it default tox0/0, rather thanx1i/0(or anything else) forlogoandimage.Click the see the script to understand the behavior
Here is a bash script to understand the default behavior in GMT:
The output is:
seisman commentedon Dec 20, 2025
@GenericMappingTools/pygmt-maintainers
I've completed most of the embellishment-plotting methods across several PRs. Their complexity varies, so it's better to review them one by one, from the simplest to the most complex. It makes more sense to have all these changes done in v0.18.0, so we may delay the v0.18.0 release by a few weeks.
The PRs are listed below in order of complexity:
Figure.logo: Figure.logo: Add parameters position/width/height to specify logo position and dimensions #4014Figure.inset: Figure.inset: Add parameters position/width/height to specify inset position and dimensions #4047Figure.legend: Figure.legend: Add parameters position/width/height/line_spacing to specify legend position and properties #4046Figure.wiggle: Figure.wiggle: Add parameters position/length/label/label_alignment for the scalebar position and properties #4049Figure.image: Figure.image: Add parameters position/width/height/dpi/replicate to control image position and properties #4045Figure.scalebar: Add Figure.scalebar to plot a scale bar on maps #4015Figure.directional_rose: Add Figure.directional_rose to plot a directional rose on map #4025Figure.magnetic_rose: Add Figure.magnetic_rose to plot a magnetic rose on map #4051Figure.colorbar: Figure.colorbar: Add position/length/width and more parameters to specify colorbar position and properties #4048 [The most complicated one, and WIP]seisman commentedon Jan 2, 2026
Here is a summary table for the parameter names that control the dimensions of the embellishments:
Figure.logowidthorheightFigure.insetwidth,heightFigure.legendwidth,heightFigure.imagewidth,heightFigure.colorbarlength,widthFigure.wigglelengthFigure.scalebarlengthFigure.directional_rosewidthFigure.magnetic_rosewidth