GenericMappingTools / GenericMappingTools/gmt
Left-aligned annotations for the right-side Y axes and colorbars?
- Dominant language
- C
- Stars
- 979
- Forks
- 414
- Avg merge
- 17h 26m
- Merged PRs (30d)
- 54
Description
Left-aligned annotations for the right Y axis have been a de facto standard, see `gnuplot`, `matplotlib`, etc
see e.g. https://gnuplot.sourceforge.net/demo_6.0/multiaxis.html for gnuplot
https://matplotlib.org/stable/gallery/subplots_axes_and_figures/secondary_axis.html for matplotlib, specifically https://matplotlib.org/stable/_images/sphx_glr_secondary_axis_005.png further down
The same request applies for `colorbar` annotations. See examples here https://gnuplot.sourceforge.net/demo_6.0/pm3d.html. `gnuplot` apparently does special treatment for the negative tick annotations, excluding the minus sign from the alignment and adding an extra minus-length-sized offset. `matplotlib` does not seem to do that.
It appeared to be relatively easy to create a workaround for the 2d plotting, right Y axis annotations, positive values (w/o the minus sign). Not clear at all how to do this for the `colorbar` annotations unfortunately.
GMT by default provides the right Y axis annotations aligned to the right, same for ` gmt colorbar` (`gmt colorbar` not shown). Further down is the desired result (positive values only). In case negative values present, there should be an extra offset from the axis equal to the length of that long minus sign character plus some extra (the distance between that minus and the following digit). Not sure how to include this into the workaround, suggestions are very welcome:
```
gmt basemap -R-500/500/-500/500 -JX5c -BWSNE -Bpy500f -Bpx500f -png right-annots
```
See below the desired result. In case negative values present, there should be an extra offset from the axis equal to the length of that long minus sign character plus some extra (the distance between that minus and the following digit). Not sure how to include this into the workaround, suggestions are very welcome:
```
gmt begin left-annots png
gmt basemap -R0/1000/0/1000 -JX5c -Bwsne -Bpy500f -Bpx500f
#Y annots on the right
gmt text -F+fred+jML -Dj6p -N << EOF
1000 0 0
1000 500 500
1000 1000 1000
EOF
gmt end show
```
See the red-colored left-aligned Y axis annotations:
Contributor guide
Assessment
This issue has not been assessed yet.