-
Notifications
You must be signed in to change notification settings - Fork 380
Better auto-legend horizontal spacing #6163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
feature request
Request a new feature
Comments
Because of the padding in the frame, the better solution is this:
Here, unit is the height of the current annotation font and size is the symbol size (or contour|vector length). This works very well and I will be making a PR soon. |
@PaulWessel, can this be closed now (based on #6165)? |
Yes I believe so |
seisman
added a commit
to GenericMappingTools/pygmt
that referenced
this issue
Apr 25, 2022
The changes are caused by upstream changes in GenericMappingTools/gmt#6163.
69 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description of the desired feature
For historical reasons, the input to legend for a symbol has this syntax:
S [dx1 symbol size fill pen [ dx2 text ]]
where dx1 is the distance from the left margin to the center of the symbol and dx2 is the distance from the left margin to the start of the optional text. If dx1 is given as "-" then we auto-compute dx1 = 0.5 * size, while if dx2 is given as "-" then we compute dx2 = 1.5 * size. For typical geometric symbols (e.g., circle) this works great: We get a gap of half the symbol size between the symbol and the text. For lines or vectors, it works not so well. Consider placing a contour or vector that is 1 cm via
-l"My vector"
. Then, the label will start 0.5 cm after the vector and the gap is starting to seem too big. Go to 2 cm and now you have a big gap. This is essentially one of the challenges for adding -l to grdvector and velo (there are others). Note: If you placed the label with a tight frame (no offset, i.e. +o0) then the symbol would be tangent to the left frame. In reality we have a default offset of 0.2 cm so the left gap in all the auto-legend examples is basically 0.2 cm. This also does not scale well for large posters.I think there are two elements of scale here:
Seems to me it would be better if dx2 involves a mix of symbol size and font size. E.g., instead of the above definition for an auto dx2, perhaps dx2 = size + 2*annot_font_size would be better. Consider a large plot on a poster: You are not going to plot a 4 cm vector and use a 10p font label. You'll be doing 24 to 32 points and you want that gap to relate to the font size. Since characters have different widths (except in Courier and similar fonts), I will consider the width of the letter M as one unit below, but it could simply be the actual font size (e.g., 12p)
My proposal is therefore to make some changes when dx1 and/or dx2 is given as "-":
This means if dx1 = dx2 = "-" (which is what we do when -l is used), we get a reasonable left-space after the margin and a getter alignment of the label text to the right of the symbol.
I will make a branch and experiment a bit with this (perhaps "one" and "two" are too little/too much and need to be adjusted). Let me know if @GenericMappingTools/core have any suggestions.
The text was updated successfully, but these errors were encountered: