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 legend symbol for confidence lines #6890

Merged
merged 5 commits into from Jul 17, 2022
Merged

Add legend symbol for confidence lines #6890

merged 5 commits into from Jul 17, 2022

Conversation

PaulWessel
Copy link
Member

Description of proposed changes

Both plot and plot3d can plot lines with build-in confidence bands. This is done via the option -L+b|d|D that reads extra column(s) to build the envelope around the line (drawn with -Wpen) and the envelope is painted via -Gfill. The envelope may also take an outline pen via -L's +ppen modifier. However, we had no way to handle this in a legend. The sad and painful process was to draw them as two separate things, then struggle a bit with a manual legend setup to draw a line on top of the rectangle for the envelope fill.

This PR detects the -L situation and basically issues to auto calls for legend entries, the first using the special symbol L for a rectangle that should not see a legend position change after it, and then the line as the second symbol which then overprints the rectangle. With this PR, simple examples like this:

#!/bin/bash
# Test CL legend
gmt math -T0/3/0.1 -N3/0 T 2 POW -C2 10 DIV 0.2 ADD = line.txt
gmt begin CL
	gmt plot -R-0.5/3.5/-1/11 -JX15c -B -L+d -W1p -Gpink line.txt -l"My trend and 2@~s@~ bounds"+jTL
gmt end show

will give a legend entry like this:

CL

@PaulWessel PaulWessel added the enhancement Improving an existing feature label Jul 16, 2022
@PaulWessel PaulWessel added this to the 6.5.0 milestone Jul 16, 2022
@PaulWessel PaulWessel self-assigned this Jul 16, 2022
@seisman
Copy link
Member

seisman commented Jul 17, 2022

Looks great, but why is the rectangle a little shorter than the line?

@PaulWessel
Copy link
Member Author

Couple of reasons:

  • I happen to like it over the alternative
  • This required no code changes for the rectangle, it is the same used for polygons

To make it the same width as the line would require more coding of a special case. Seems not worth it to me.

@seisman
Copy link
Member

seisman commented Jul 17, 2022

Couple of reasons:

  • I happen to like it over the alternative
  • This required no code changes for the rectangle, it is the same used for polygons

To make it the same width as the line would require more coding of a special case. Seems not worth it to me.

Sounds reasonable to me.

@PaulWessel PaulWessel merged commit e280ff5 into master Jul 17, 2022
@PaulWessel PaulWessel deleted the confidence-line branch July 17, 2022 10:26
@maxrjones maxrjones added the add-changelog Add PR to the changelog label Dec 8, 2023
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 enhancement Improving an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants