gnuplot contour line color: set style line and set linetype not working

后端 未结 3 1820
无人共我
无人共我 2020-12-05 12:14

I am plotting data as described in a previous Stackoverflow question: gnuplot 2D polar plot with heatmap from 3D dataset - possible? Mostly it is working well for me, and I

3条回答
  •  心在旅途
    2020-12-05 13:03

    Here is how you can change the line properties of the contour lines. I can't explain why it is that way, I just found out by testing it. Unfortunately, there is no documentation about these details.

    The behaviour is as follows (tested with 4.6.3. and 4.7 (2013-07-25 and 2013-09-09), all show the same behaviour):

    Default settings

    1. If no linetype is specified for splot, the surface itself would use lt 1. In that case the first contour is drawn with lt 3. Yes, the numbering is backwards compared to the specified increment. But you can reverse it by using set cntrparam levels increment -6,-6,-18 or set cntrparam levels increment -18,6,-6

    2. The linewidth of all contours is the same and also equal to the linewidth used for the plotting command, to change it use e.g. splot 'new_test.dat' lw 3.

    The result (without the thicker lines) is as shown in the question.

    Using linestyles

    1. The contours use the linestyle with an index by one higher than the one used by the plotting command.

    2. You must also define the first linestyle, which would be used by the surface. If this style is not defined, the contours fall back to using linetype.

    3. The linewidth is taken from the first linestyle, all lw settings from the following ls are ignored.

    Using customized linetypes

    1. The contours use the linetype with an index by one higher than the one used by the plotting command.

    2. All linetype must be customized, also the first, the one used by the surface. Otherwise the default settings are used.

    3. lw same as for linestyle.

    For testing I used your data and the following stripped down script:

    reset 
    set terminal pngcairo size 800,800 
    set output '3d-polar.png'
    
    set lmargin at screen 0.05
    set rmargin at screen 0.85
    set bmargin at screen 0.1
    set tmargin at screen 0.9
    
    set pm3d map interpolate 20,20
    
    # plot the heatmap
    set cntrparam bspline
    set cntrparam points 10
    set cntrparam levels increment -6,-6,-18
    set contour surface
    
    set palette rgb 33,13,10
    set cbrange [-18:0]
    
    unset border
    unset xtics
    unset ytics
    
    set angles degree
    r = 3.31
    set xrange[-r:r]
    set yrange[-r:r]
    set colorbox user origin 0.9,0.1 size 0.03,0.8
    
    # load one of the following files:
    #load 'linestyle.gp'
    #load 'linetype.gp'
    
    splot 'new_test.dat' title ' '
    

    The cbrange is defined only down to -18, so I changed the contour levels accordingly (-24 wasn't drawn anyway).

    The two 'contour settings files', which I use are:

    linetype.gp:

    set linetype 1 lc rgb "blue" lw 3
    set linetype 2 lc rgb "black"
    set linetype 3 lc rgb "orange"
    set linetype 4 lc rgb "yellow"
    

    linestyle.gp:

    set style increment user

    set style line 1 lc rgb 'blue' lw 3
    set style line 2 lc rgb 'black'
    set style line 3 lc rgb 'orange'
    set style line 4 lc rgb 'yellow'
    

    Both give the same output image:

    enter image description here

    To use this for your complete script, just load one of the two files directly before the splot command. This gives the output:

    enter image description here

    After your first question about contours, I was about to submit a bug report, but it turned out to be rather difficult to boil it down to concrete questions. With this question it might be easier. I'll see if I find some time to do this.

提交回复
热议问题