Skip to content
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

Add -l to grdvector for legend entry #6199

Merged
merged 19 commits into from
Jan 11, 2022
Merged

Add -l to grdvector for legend entry #6199

merged 19 commits into from
Jan 11, 2022

Conversation

PaulWessel
Copy link
Member

This PR adds -l to the grdvector repertoire. The magnitude of the legend vector (in data units) can be set via -S modifier +srefval. Note that -l requires Cartesian vectors as geovectors do not have a constant representation on a map w.r.t. a reference length but can vary with position and projection. A simple new test (veclegend.sh) demonstrates the effect:

gmt grdmath -R0/30/30/60 -I5 -fg X = x.grd
gmt grdmath -R0/30/30/60 -I5 -fg Y 30 SUB = y.grd
# Set the LL grid values to the same as the UR values
echo 0 30 30 > t.txt
gmt grdedit -Nt.txt x.grd
gmt grdedit -Nt.txt y.grd
# Use reference length as 25 mm/year in the legend
gmt begin veclegend
	gmt grdvector x.grd y.grd -R-2/38/29/65 -JM15c -B -Q14p+e+n25q/0 -Gred -W1p -S15c+s25 -l"Velocity (25 mm/yr)"
	echo 13 47 | gmt plot -Sc0.1i -Gblue -l"Arbitrary point"
gmt end show

veclegend

A few minor issues had to be fixed, such as an update to the plate.ps original, and a special check to honor grdvector settings for shrinking which are assumed to be in data units unless an actual unit is added (outside grdvector we expect to see the unit q for this).

Pinging @gd-a as well for information.

@PaulWessel PaulWessel added the new feature PR that implements a new feature or capability in GMT label Jan 8, 2022
@PaulWessel PaulWessel added this to the 6.4.0 milestone Jan 8, 2022
@PaulWessel PaulWessel self-assigned this Jan 8, 2022
@gd-a
Copy link
Contributor

gd-a commented Jan 10, 2022

vectors as geovectors do not have a constant representation on a map

Hi @PaulWessel,

Indeed, but we could still use a reference like
"10 m/s at 25ºN"

25ºN being defined manually through -l+m25 or -l+m+25 (m for manual)

@PaulWessel
Copy link
Member Author

Since the latitude 25N has no bearing on the plotted length of the arrow, you would just use -l"10 m/s". The only arrows that vary with latitude would be geovectors and right now grdvector does not allow -l with those due to their variable length. I mean, you could att "@ 25N" to your label but there is no need to pass +m25 since it has no effect.

@gd-a
Copy link
Contributor

gd-a commented Jan 10, 2022

and right now grdvector does not allow -l with those due to their variable length

That's my point, you could allow it as long as "@25n" is required (or middle latitude by default)

@PaulWessel
Copy link
Member Author

Well, it would need to be like in the map scale syntax -L. So perhaps we require +c for geovectors:

Use +c[[slon/]slat]] to control where on a geographic map the reference geovector length set via +s applies. Legend vector length is calculated for latitude slat (optionally supply longitude slon for oblique projections [default is central meridian]). If +c is given with no arguments then we select the length to be true at the middle of the map.

@gd-a
Copy link
Contributor

gd-a commented Jan 10, 2022

👍 I like that (if not too much work)

I would greatly clean some of my codes by getting rid of gmt legend multi-lines :)

@PaulWessel
Copy link
Member Author

Now, grdvector supports legends for geovector also, by requiring the +c setting. Also note that while the length of the vector is computed as discussed, the vector that is actually plotted in the legend is the Cartesian vector since there is no simple way to plot a slightly curved great circle stem there anyway.

@maxrjones
Copy link
Member

I think t.txt, t.pdf, x.grd, and y.grd in test/grdvector may have been committed by mistake. We could also remove the two postscript files because I can add them using dvc when updating the other failing tests.

@PaulWessel
Copy link
Member Author

OK, got rid of those plus gmt.history and a PDF file. yikes...

@PaulWessel PaulWessel merged commit 969aefa into master Jan 11, 2022
@PaulWessel PaulWessel deleted the grdvector-legend branch January 11, 2022 20:02
@gd-a
Copy link
Contributor

gd-a commented Jan 11, 2022

Now, grdvector supports legends for geovector also, by requiring the +c setting. Also note that while the length of the vector is computed as discussed, the vector that is actually plotted in the legend is the Cartesian vector since there is no simple way to plot a slightly curved great circle stem there anyway.

I'll update some of my scripts next month to try this
Thanks Pål !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add-changelog Add PR to the changelog new feature PR that implements a new feature or capability in GMT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants