Left-aligned annotations for the right-side Y axes and colorbars?

Open
#8,956 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
c

Research direction

Start by reproducing the examples with gmt basemap, gmt colorbar, and gmt text, then trace the existing right-side axis and colorbar annotation handling. Done means right-side Y-axis and colorbar annotations are left-aligned consistently, including the requested treatment of negative values, with behavior verified against the demonstrated cases.

Written by the indexing model from the issue text.

Description

feature request

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
Image

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:
Image

Dominant language
C
Stars
997
Forks
420
Avg merge
13h 27m
Merged PRs (30d)
47

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from GenericMappingTools/gmt

All issues in GenericMappingTools/gmt

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.