Skip to content

Proper positional adjustment of directional rose due to labels#6215

Merged
PaulWessel merged 39 commits intomasterfrom
rose-adjustment
Feb 3, 2022
Merged

Proper positional adjustment of directional rose due to labels#6215
PaulWessel merged 39 commits intomasterfrom
rose-adjustment

Conversation

@PaulWessel
Copy link
Member

See #6213 for background. This PR does a few things and raises a question (at the end):

  1. We adjust the center of the rose coordinate by the label offset amount that have been selected.
  2. We use PSL to determine the exact width and height of the label (if specified) to transform the origin by the amount.

This addresses the main concern in #6213. The PR does a few more things for modern mode:

  1. It sets the label font size to 25% of the rose diameter.
  2. It sets the label offset (gap between rose thorns and text) to be 50% of the label size.

Both of those fractions are up for discussion and refinement. Also, the classic defaults for font size (FONT_TITLE) and offset (MAP_TITLE_OFFSET for fancy and (curiously) MAP_ANNOT_OFFSET for plain) are much too large and furthermore inconsistent. We could either declare a bug here or just keep the auto-scaling to modern mode in line with other auto-scalings.

Happy to take comments on this. Below is a new test. There is one tiny issue remaining: The S label is still clipped and I cannot yet see why this can happen...

roses

Also, for modern mode reset the text font and offset based on symbol size.
Also add test script dir_roses.sh
@PaulWessel PaulWessel added bug Something isn't working enhancement Improving an existing feature labels Jan 11, 2022
@PaulWessel PaulWessel added this to the 6.4.0 milestone Jan 11, 2022
@PaulWessel PaulWessel self-assigned this Jan 11, 2022
@maxrjones
Copy link
Member

Keeping the auto-scaling to modern mode in line with other auto-scalings sounds good to me.

* Let map roses have a default size of 10% of map width

This PR makes +wwidth optional for magnetic and directional roses.  if not given we default to 10% of the map width. Alternatively, give +w with % as unit to change this value.  Closes #6211

* Set 15 and 8 % as default sizes
@PaulWessel
Copy link
Member Author

Ping @Esteban82, @joa-quim and @meghanrjones. I have implemented auto-scaling for the magnetic rose as well. Please build from this branch and use this script to explore and give feedback on the scalings I chose. FYI, I set the scales so that for size 2.5i (the original script) the roses looks similar. For smaller sizes things scale down accordingly:

#!/usr/bin/env bash
# Change W for smaller compass whose attributes scale with size
W=2.5i
gmt begin mag
	gmt set GMT_THEME cookbook
# Magnetic rose with a specified declination
	gmt basemap -R-10/-2/12.8812380332/0.661018975345+r -JOc0/0/50/60/7i -B0 -X1.25i
	gmt basemap -Tmg-2/0.5+w${W}+d-14.5+t45/10/5+i0.15p,blue+p0.15p,red+l+jCM \
		--FONT_ANNOT_PRIMARY=9p,Helvetica,blue --FONT_ANNOT_SECONDARY=12p,Helvetica,red --FONT_LABEL=14p,Times-Italic,darkgreen \
		--MAP_FRAME_WIDTH=10p --COLOR_BACKGROUND=green --MAP_DEFAULT_PEN=2p,darkgreen --COLOR_BACKGROUND=darkgreen \
		--MAP_VECTOR_SHAPE=0.5 --MAP_TICK_PEN_SECONDARY=thinner,red --MAP_TICK_PEN_PRIMARY=thinner,blue
EOF
gmt end show

See gmt_plot.c line 3308 for where the scales are - feel free to experiment changing those numbers if you think they can be improved.

Note: I have not yet dealt with positions and adjustments due to text size as I have done for directional rose - that comes later.

@maxrjones
Copy link
Member

Would auto-scaling for the intervals typically set using +t be possible? Or an option to apply MAP_ANNOT_MIN_SPACING to those?

@PaulWessel
Copy link
Member Author

NZ: These are tiny maps (3i) so default symol is 0.3 inches or about 0.75 cm. It is small - the original had a fixed 0.5i symbol. I can restore to 0.5i but will still fail due to (now) correct placement. This figure is included in the cylindrical doc section so we do want it to be readable. OK, have set it back to 0.5i since the script is not shown anyway.

There have been no change to which font is used, only size of that font.

@maxrjones
Copy link
Member

NZ: These are tiny maps (3i) so default symol is 0.3 inches or about 0.75 cm. It is small - the original had a fixed 0.5i symbol. I can restore to 0.5i but will still fail due to (now) correct placement. This figure is included in the cylindrical doc section so we do want it to be readable. OK, have set it back to 0.5i since the script is not shown anyway.

The rose on the right panel looks to still be shrunk:
image

There have been no change to which font is used, only size of that font.

Ah, as you said it is set by FONT_TITLE which is Helvetica-Bold.

My main concern is about MAP_EMBELLISHMENT_MODE taking precedence over FONT_TITLE in this PR. I think that a user should not need to set both MAP_EMBELLISHMENT_MODE=manual and FONT_TITLE=9p for their font preference to be applied, since they may prefer auto offset with a specific font size or already have scripts in modern mode with a specific font size. For example, the relevant line in GMT_obl_nz.sh sets --FONT_TITLE=9p but this does not affect the plot in this PR.

@PaulWessel
Copy link
Member Author

TYpo in script, now same size.
As for FONT: yes the 9p has no effect. I see the auto affecting lots of parts and it would make little sense to micro-manage font sizes from the user. THis is an older script so I should just remove that setting (predates this PR).

@maxrjones
Copy link
Member

As for FONT: yes the 9p has no effect. I see the auto affecting lots of parts and it would make little sense to micro-manage font sizes from the user. THis is an older script so I should just remove that setting (predates this PR).

Do you mean that you prefer the current behavior in this PR of MAP_EMBELLISHMENT_MODE overriding FONT_TITLE settings?

@PaulWessel
Copy link
Member Author

Yes, because I do not know how to track what was set manually. Remember, this is after the auto-scaling of fonts etc have already been set for the map. So without a set of book-keeping I would not know if I should not change the font-size because the user wanted 24p. They can change the font, but not manually set a size and still benefit from all the other auto-things. I think the vast amount of users will be pleased they dont have to think about these settings, and a few may wish to do things entirely manually.

@maxrjones
Copy link
Member

OK, I think it's good to go after removing the now irrelevant settings from the scripts.

Comment out a debug section
@PaulWessel
Copy link
Member Author

FYI: This PR got delayed a bit because the alignment of the N-arrow in example 4 was off. The solution is to temporarily reset the PostScript matrix projection, compute the offsets, then reinstate the projection (the -p60/30 as implemented in PostScript) as the offsets need to be measured without perspective. Now, ex04 has a good default placement and size I think. About 8 tests related to map roses, including some new tests with no PS files, fail. I think we will add these to dvc soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement Improving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants