Menu

#1612 Contours not corrected dashed

None
closed-fixed
nobody
None
2017-10-22
2015-05-13
James Shaw
No

Rendering contour lines with dashed lines (e.g. dt 2 or dt 3) does not correctly dash lines -- they are solid in some places.

I've tested this by using "set table" to output the contour data, then plotting it with the same dash type. I've attached the script and dataset.

Tested with wxt and svg terminals using gnuplot 5.0 patchlevel 0

5 Attachments

Discussion

  • James Shaw

    James Shaw - 2015-05-13
    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -2,3 +2,4 @@
     splot-contours.png (43.4 kB; image/png)
     plot-precalculated-contours.png (47.5 kB; image/png)
     plot-precalculated-contours.plt (297 Bytes; application/octet-stream)
    +diff10000.dat (392.6 kB; application/octet-stream)
    
    • Group: -->
    • Priority: -->
     
  • Karl Ratzsch

    Karl Ratzsch - 2015-05-17

    The interpolated points on the contour seem to get connected not by one continous line but individual lines, making the dash pattern restart at every point. Following plot reproduces the same problem.

    set samp 50; set xr [0:3]; set yr [-3:3]
    set view map; unset surface; set contour
    splot 1/(1+x**2+y**2) w l dt 2
    

    (I'll set up a feature request addressing the ugly sampling in my example, that's not easily fixable.)

     

    Last edit: Karl Ratzsch 2015-05-17
  • Ethan Merritt

    Ethan Merritt - 2015-05-18

    As Karl notes, the issue is that for many output devices (a.k.a. terminals) the dash pattern only comes out right for single continuous lines, not for a collection of end-to-end line segments. The contouring algorithm is an one example of this effect, some of the curve-smoothing routines also illustrate this problem.

    A possible workaround is to use "set table" to write the contours out to a file, then read the file back in in a separate plot command. This bypasses the problem by collecting the line segments making up a contour into longer "polylines" that suffer fewer artifacts from dash pattern code.

     
    • Karl Ratzsch

      Karl Ratzsch - 2015-05-20

      I noticed that in table mode, "splot .. nosurface" still prints the gridded data (+the contour)? Issuing "unset surface" before works as expected.

       
  • Ethan Merritt

    Ethan Merritt - 2015-05-20

    Table mode is pretty dumb. It bypasses most of the plot-specific details and just dumps the stored coordinates.

     
  • Ethan Merritt

    Ethan Merritt - 2015-06-03

    A fix for this problem is now in cvs for 5.0 and 5.1. It will be included in the release package for 5.0.1, which will happen real soon now.

     
  • Ethan Merritt

    Ethan Merritt - 2015-06-03
    • status: open --> pending-fixed
     
  • Karl Ratzsch

    Karl Ratzsch - 2015-06-03

    I noticed one other hitch with contour lines: The colour can be controlled via "set linetype", but not dashtypes and linewidths. Those settings are simply ignored.

     
  • Ethan Merritt

    Ethan Merritt - 2015-06-08
    • status: pending-fixed --> closed-fixed
     
  • David Kastrup

    David Kastrup - 2017-10-19

    Dashed contour lines in epslatex terminal with current 5.2.0 plus patch enabling dashtypes. Does not look like the dashed contour lines work yet here.

     
  • David Kastrup

    David Kastrup - 2017-10-22

    "Ethan Merritt" sfeam@users.sf.net writes:

    That is exactly what I warned about when I offered the patch. Some
    terminal types start the dash pattern over again for each line segment
    drawn, which clobbers the overall continuity.

    Looks like something that should not really be left to the discretion of
    the terminal, or the likes of issue 1612 will get redone time and again.

    At any rate, this is kind of important for getting useful graphics and
    it would be a real annoyance if at this stage in generation of my plots
    I had to restart from scratch using a different graphics program. Any
    suggestions what I might try here instead?

    --
    David Kastrup

     
    • David Kastrup

      David Kastrup - 2017-10-22

      Oh, and to nib one idea in the bud: the tikz terminal suffers from the same symptom. And to add insult to injury, Gnuplot 4.6's epslatex terminal in dashed mode (apart from rather random assignments of colors, including different colors for parts of the same contour height) does not dash well, either: basically if you have a zigzagging line, some directions are dashed, the opposite direction may be not. While it doesn't appear to have the restarting dash pattern problem, dash patterns don't work in some directions.

       
  • Ethan Merritt

    Ethan Merritt - 2017-10-22

    Dashed lines and gnuplot's current hidden3d mode are intrinsically incompatible. it is not specific to contour lines. In order to figure out which bits of the scene occlude which other bits of the scene, all of the line segments making up all the scene elements are sorted along the line of sight so that only the top line segment (closest to the viewer) is kept. This means that all of the little line segments making up a single longer line, for example a contour line, get separated from each other. When they are then drawn one by one the fractional progress through a dot-dash pattern is lost.

    I do not see a way around this given the current set of algorithms that have been implemented.
    About the only alternative that occurs to me would be to treat every dot or dash making up the line as a separate object rather than as part of a vector. I.e. instead of drawing a dotted line, the program would place N separate dots along the path where the line would have been. But no such drawing mode currently exists in gnuplot.

     
    • David Kastrup

      David Kastrup - 2017-10-23

      Sounds to me like all that would be required is almost-drawing everything once without starting the hidden3d algorithm and recording for each line piece the starting phase of the dash pattern (possibly just accumulated line length will be precise enough for most practical purposes if the exact pattern length to be used is not yet known). Then you can sort and redraw in arbitrary order.

      That would not require a significant adaptation of the algorithms, just recording some additional information while working with the current "workhorse" algorithms.

       
      • David Kastrup

        David Kastrup - 2017-10-23

        Actually, for base contours I'd expect the contours to be completely below the surface and planar, so just drawing them unsorted first before starting with the surface should suffice for most (if not all) workloads.

         
        • David Kastrup

          David Kastrup - 2017-10-23

          Any chance to do this drawing contours (without hidden3d) and surface (with hidden3d) in separate commands, combined into one graphic? I haven't quite got the hang of how replot works.

           

Log in to post a comment.