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

plot -Sf gap - unwanted size change #2995

Closed
KristofKoch opened this issue Mar 30, 2020 · 13 comments
Closed

plot -Sf gap - unwanted size change #2995

KristofKoch opened this issue Mar 30, 2020 · 13 comments
Milestone

Comments

@KristofKoch
Copy link
Contributor

Description of the problem

When using -Sf the size of the gap between the symbols changes depending on supplied path.

  • Two identical fronts are used for illustration, boxes are 80p in size with a 160p spacing.
  • The right (blue) front is shifted 80p to create an alternating pattern.
  • The paths both run from bottom right to upper left.
  • In both examples the plot call is absolutely identical, only the supplied path changes.

Full script that generated the error

cat > path.txt << END
 1.3 -1.5
-1.8  1.2
END

cat > path2.txt << END
 1.3 -1.5
 0.2  0.4
-0.8  0.1
-1.8  1.2
END

gmt begin small_gap
  gmt basemap -R-2/2/-2/2 -JM6i -Bafg1
  gmt plot path.txt -W0p -Sf160p/80p+b+l+pred
  gmt plot path.txt -W0p -Sf160p/80p+b+r+pblue+o80p
  gmt plot path.txt -Skcrosshair/0.5c -Wthinnest,black
gmt end show

gmt begin large_gap
  gmt basemap -R-2/2/-2/2 -JM6i -Bafg1
  gmt plot path2.txt -W0p -Sf160p/80p+b+l+pred
  gmt plot path2.txt -W0p -Sf160p/80p+b+r+pblue+o80p
  gmt plot path2.txt -Skcrosshair/0.5c -Wthinnest,black
gmt end show

Actual outcome

small_gap

large_gap

The two different paths lead to two different gap sizes all other things being the same.

Expected outcome

I expected the gaps to be as wide as the boxes and not changing size depending on supplied path in an unpredictable manner.

System information

  • Operating system: macOS
  • GMT version: a6f3e31
@KristofKoch
Copy link
Contributor Author

Some further experimentation lead me to believe that this might actually be an intentional feature. By sightly nudging the gap size the line terminates on a symbol making for a nice line end. This is hardly noticeable at small symbol sizes but gets very obvious at larger sizes as shown above.

cat > path.txt << END
 1.3 -1.5
-1.8  1.2
END

gmt begin small_gap
  gmt basemap -R-2/2/-2/2 -JM6i -Bafg1
  gmt plot path.txt -W0p -Sf160p/80p+b+l+pred
  gmt plot path.txt -W0p -Sf160p/80p+b+r+pblue+o80p
  gmt plot path.txt -W0p -Sf80p/40p+b+l+pred
  gmt plot path.txt -W0p -Sf80p/40p+b+r+pblue+o40p
  gmt plot path.txt -W0p -Sf16p/8p+b+l+pred
  gmt plot path.txt -W0p -Sf16p/8p+b+r+pblue+o8p
  gmt plot path.txt -W0p -Sf8p/4p+b+l+pred
  gmt plot path.txt -W0p -Sf8p/4p+b+r+pblue+o4p
  gmt plot path.txt -Skcrosshair/0.5c -Wthinnest,black
gmt end show

See this heavily zoomed in crop of above test:

Bildschirmfoto 2020-03-30 um 23 02 08

The uneven gap is always there, it just get less and less noticeable the smaller the symbol gets.

I would have never noticed this if not for my attempt for a checkered line. Can someone confirm my suspicions?

@PaulWessel
Copy link
Member

Remember that for geographic data, the default behavior is to resample crude paths with great-circle resampling. This can be modified or turned off with -A. So here, the paths you are prescribing are not the ones being used inside plot. Please try with -A and see if there are any issues then,

@KristofKoch
Copy link
Contributor Author

Hi @PaulWessel, I tried again with -A as suggested but same result. In my understanding there should be not much difference between a great circle and a crude path with this projection and region?

cat > path.txt << END
 1.3 -1.5
-1.8  1.2
END

gmt begin small_gap_A
  gmt basemap -R-2/2/-2/2 -JM6i -Bafg1
  gmt plot path.txt -W0p -Sf160p/80p+b+l+pred -A
  gmt plot path.txt -W0p -Sf160p/80p+b+r+pblue+o80p -A
  gmt plot path.txt -Skcrosshair/0.5c -Wthinnest,black
gmt end show

Same result when using -A:

small_gap_A

@PaulWessel
Copy link
Member

Thanks, @KristofKoch. If you want to be sure you can plot your points as well with and without -A and see if they differ.

@KristofKoch
Copy link
Contributor Author

I have the feeling I'm not understanding your argument but I do not see how the points could be influenced by -A?

cat > path.txt << END
 1.3 -1.5
-1.8  1.2
END

gmt begin small_gap_A
	gmt basemap -R-2/2/-2/2 -JM6i -Bafg1
  gmt plot path.txt -W0p -Sf160p/80p+b+l+pred -A
  gmt plot path.txt -W0p -Sf160p/80p+b+r+pblue+o80p -A
  gmt plot path.txt -Skcrosshair/0.5c -Wthinnest,black
  gmt plot path.txt -Skcrosshair/0.5c -W0p,pink -A
gmt end show

Crop from resulting plot - they match perfectly

point with A

@PaulWessel
Copy link
Member

I mean where the points plot with vs without -A.

@KristofKoch
Copy link
Contributor Author

My apologies @PaulWessel, but I think I still don't understand it. You mean comparing the placement of the two points from the textfile? This is what I tried with the exaggerated bullseye above: black without -A and the faint pink superimposed one with -A.

@PaulWessel
Copy link
Member

Looking at the source code for gmt_draw_front:

if (f->f_gap > 0.0) {	/* Gave positive interval; adjust so we start and end with a tick on each line */
	ngap = irint (s[n-1] / f->f_gap);
	gap = s[n-1] / ngap;
	dist = f->f_off;	/* Start off at the offset distance [0] */
	ngap++;
}

So looks like we are marching along the line in steps of gap, which can differ from the given gap (f_gap) and that difference is likely to be larger fro fewer gaps.

@KristofKoch
Copy link
Contributor Author

KristofKoch commented Mar 31, 2020

So my suspicions were right – the user supplied gap is more of a "recommendation". As far as I understand gmt_plot.c (no real C experience) there is no way to easily force an exact gap. Thank you for pointing that out, @PaulWessel

Is there a way to suppress the plotting of the line? Something like -W- then I would be able to get a wider spacing and wash over the "flexible" gap and have more leeway to toy around with --PS_LINE_CAP to generate different line designs.

@KristofKoch
Copy link
Contributor Author

To highlight my point why a not plotted line would be beneficial (for me at least) see the following example. All styles without a distinct centerline have a problem with the (very faint) line.

small_tick

@PaulWessel
Copy link
Member

Thanks @KristofKoch, I will look at the front symbol option for improvements. It should be possible to not draw the line. You are probably aware of the decorated symbol option as well (-S~); is that of interest to you as well?

@KristofKoch
Copy link
Contributor Author

For some inexplicable reason I wasn't aware of -S~.

head -> desk (repeatedly)

This promises to solve quite a few headaches (not the head banging – the -S~ option). Even my dashed line with arrow heads problem.

Thank you, @PaulWessel - now I have a lot to test and experiment. And thank you for looking into -Sfas well.

PaulWessel added a commit that referenced this issue Apr 1, 2020
If the front gap is specified with an explicity plus-symbol then we take taht to mean the gap should be used as is.  The default remains to distribute ticks exactly along the liine and thus adjust the gap accordingly.  See #2995 for context.
@seisman seisman added this to the 6.1.0 milestone Apr 1, 2020
PaulWessel added a commit that referenced this issue Apr 1, 2020
* Let positive front gaps be used as given

If the front gap is specified with an explicity plus-symbol then we take taht to mean the gap should be used as is.  The default remains to distribute ticks exactly along the liine and thus adjust the gap accordingly.  See #2995 for context.

* Update gmt_init.c
@PaulWessel
Copy link
Member

Hi @KristofKoch, I will close this one for now. Feel free to open an issue about allowing the lines in quoted, decorated, and front to be invisible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants