Gnuplot line outline color: setting the style line and setting the line type does not work

I draw data as described in a previous Stackoverflow question: A gnuplot 2D plot with a heat map from a 3D dataset - maybe? It basically works well for me, and I bring it to the little details. One such way is to control the colors of the outline line and the line widths. There are many reports on the Internet about using set style increment user , followed by defining a user's style through set style line 1 lc rgb "blue" lw 2 , etc. Theoretically, this was supposed to make splot build storylines using new defined styles. I tried and it didn't work. Also, when I went to the help pages through my gnuplot installation, I found that this use was deprecated with my version (version 4.7 patchlevel 0 of the latest modification 2013-07-25). Instead, it was recommended that you use the specified line type, which constantly changes the gnuplot line style characteristics for the current gnuplot call. Killing and restarting gnuplot restores the default line type characteristics.

Then I restarted gnuplot, restored the chart without overriding any line style or type for contour lines. When I looked at my plot, I saw that the colors of the lines begin with cyan, then magenta, then blue (for example, the type of lines 5,4,3 or 14,13,12, etc.). It seems that line types go BACKWARDS through the available styles. Well, I thought, I can just change them and live with odd behavior. However, after issuing several line set commands that changed all of these line types to something that would be clearly different (I checked them by running the test command, the contour lines on the chart still had the same color and line width as Before, I cannot understand what type of lines is used for contour lines, so I cannot change the corresponding type of line.

Perhaps this odd behavior is the result of the contour line being of the type set cntrparam levels increment -6,-6,-24 , and negative values ​​and / or negative incremental increment cause some unpredictable behavior?

I would like to know how I can find out what type of lines will be used for contour lines in this graph, and whether it will change if the number of lines used to construct the surface change changes. For example, the graph shown below uses 13 “lines” to generate a surface using the set pm3d map . So, let N = 13 lines - is there a rule that holds for the first type of line contour ?. For example, will I always be sure that the outline line style starts with N = 14? I would like to know what type of line will be used for the first and subsequent contour lines, when the number of “lines” in my input will change.

The bottom line is that I need to apply a certain style to the contour lines used for each level of the contour. I want to consistently use the same style for each level when changing the input. The plot will always use the same set of contour levels: -6, -12, -18 and -24. The chart data will always have a maximum "z" coordinate of about 0 and decrease from there.

Gnuplot commands are shown below. The dataset for this story can be downloaded here: http://audio.claub.net/temp/new_test.dat

 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 unset key set multiplot # plot the heatmap set cntrparam bspline set cntrparam points 10 set cntrparam levels increment -6,-6,-24 set contour surface #set style increment user #NOTE: the commented out lines do not seem to affect color or width of the the contour lines no matter what number I use for the linetype #set linetype 8 lc rgb "blue" lw 2 #set linetype 9 lc rgb "black" lw 1 #set linetype 10 lc rgb "orange" lw 1 #set linetype 11 lc rgb "yellow" lw 1 set palette rgb 33,13,10 #rainbow (blue-green-yellow-red) set cbrange [-18:0] unset border unset xtics unset ytics set angles degree r = 3.31 #This number is Log10(max frequency) - Log10(min frequency) of the polar frequency grid set xrange[-r:r] set yrange[-r:r] set colorbox user origin 0.9,0.1 size 0.03,0.8 splot 'new_test.dat' # now plot the polar grid only set style line 11 lc rgb 'black' lw 2 lt 0 set grid polar ls 11 set polar set logscale r 10 set rrange[10:20000] unset raxis set rtics format '' scale 0 #set rtics axis scale set rtics (20,50,100,200,500,1000,2000,5000,10000,20000) do for [i=-150:180:30] { dum = r+0.15+0.05*int(abs(i/100))+0.05*int(abs(i/140))-0.05/abs(i+1) set label i/30+6 at first dum*cos(i), first dum*sin(i) center sprintf('%d', i) } set label 20 at first 0, first -(log(20)/log(10)-1) center "20" set label 100 at first 0, first -(log(100)/log(10)-1) center "100" set label 200 at first 0, first -(log(200)/log(10)-1) center "200" set label 1000 at first 0, first -(log(1000)/log(10)-1) center "1k" set label 2000 at first 0, first -(log(2000)/log(10)-1) center "2k" set label 10000 at first 0, first -(log(10000)/log(10)-1) center "10k" set label 20000 at first 0, first -(log(20000)/log(10)-1) center "20k" plot NaN wl unset multiplot unset output 

A graph without control over contour lines is shown below. I need to specify the color and line width for contour lines. How?

polar sonogram with default contour line styles

+7
colors gnuplot contour
source share
2 answers

Here's how you can change the properties of a contour line line. I can’t explain why this is so, I just found out by testing it. Unfortunately, documentation about these details is missing.

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

Default settings

  • If splot not specified for linetype , the surface itself will use lt 1 . In this case, the first contour is drawn using lt 3 . Yes, backward numbering compared to the specified increment. But you can undo it using set cntrparam levels increment -6,-6,-18 or set cntrparam levels increment -18,6,-6

  • linewidth all the contours is the same as well as the equal linewidth used for the linewidth command to change its use, for example. splot 'new_test.dat' lw 3 .

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

Using linestyles

  • Outlines use linestyle with an index one higher than the one used by the build team.

  • You must also determine the first linestyle to be used by the surface. If this style is not defined, the paths revert to linetype .

  • linewidth is taken from the first linestyle , all lw settings from the following ls ignored.

Using custom linetypes

  • Outlines use linetype with an index one higher than that used by the build command.

  • All linetype must be configured, as well as the first used by the surface. Otherwise, the default settings are used.

  • lw the same as for linestyle .

For testing, I used your data and the following split the 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 ' ' 

cbrange is only defined to -18 , so I changed the outline levels accordingly ( -24 not drawn anyway).

Two "contour settings files" that I use:

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 custom style gain

 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, simply upload one of the two files immediately before the splot command. This gives the result:

enter image description here

After your first question about the contours, I was going to submit a bug report, but it turned out to be rather difficult to reduce to specific questions. With this question it could be easier. I will see if I find time for this.

+6
source share

I had to come back to this question when I again did the GNUplot graphics, this time in rectangular coordinates, and found that I could not remember how to control the line type for contour lines.

I found that the above information is not entirely correct right now, and I found a way to explain how this works with GNUplot version 5 patchlevel 3.

There are three things that I found to manage contour lines: 1. the set cntrparam levels increment command and 2. the set style increment user command and 3. the line style list (I used the set style command)

Turns out it's a bit complicated. Let me give you an example or two of my own code:

 #HOW TO CONTROL LINE COLOR AND WIDTH FOR CONTOUR LINES: #the number of contour lines and their level is controlled using the 'set cntrparam' command, above #the 'set cntrparam' has the format 'start,increment,end' for the line positions #note that the end level is listed at the top of the key/legend for the lines! #line style 1 is used elsewhere, not for contour lines #line style 2 is used for the style of the last line (eg end, or the last one drawn) #line styles for other lines begins further down the list of styles and works UPWARDS to line style 2 #example 1: three lines at -40, -30, and -20 # set cntrparam levels increment -20,-10,-40 # set style line 1 lw 0.5 lc "grey30" # set style line 2 lw 0.5 lc "blue" # set style line 3 lw 0.5 lc "white" # set style line 4 lw 0.5 lc "red" # This results in: # -20 line color is RED # -30 line color is WHITE # -40 line color is BLUE # #example 2: four lines at -35, -30, -25, and -20 # set cntrparam levels increment -20,-5,-35 # set style line 1 lw 0.5 lc "grey30" # set style line 2 lw 0.5 lc "blue" # set style line 3 lw 0.5 lc "white" # set style line 4 lw 0.5 lc "red" # set style line 5 lw 0.5 lc "yellow" # This results in: # -20 line color is YELLOW # -25 line color is RED # -30 line color is WHITE # -35 line color is BLUE 

I hope others find this helpful and informative. Perhaps Christoph (if he reads this topic) can comment, since GNUplot is an evolving tool, and he will know more about it.

+2
source share

All Articles