Linewidth smaller than 1 - plot

I would like to plot these data
1 2
2 3
3 5
4 5
5 6
with this code
set ter pdfcairo enhanced color solid
set out "test.pdf"
set xrange [-.5:4.5]
set yrange [.5:6.5]
unset key
plot "test.txt" u 0:1,"" u 0:2, "" u 0:1:(0):($2-$1) with vectors nohead lw 0.5
The line width command seems to work, but it seems not to work with a line width smaller than 1.
this plot is with line width 5:
this plot is with line width 1
this plot is with line width 0.2
as one may notice, there is no difference between the latter two plots. How can I force gnuplot to use a line width smaller than 1?

Related

gnuplot palette for splot 3D surface of errors: symmetrical colors

I am plotting a 3D surface (I have z values on a matrix 8x10 in a text file); The z values represent the error, so it goes e.g. from -20% to +10%. I would like to plot this with colors, in a symmetric way, meaning e.g. -10% needs to be the same red intensity as +10%. The value around 0% (very small errors) needs to be green (or also blue or whatever). So in this way the more intense the red is, the greater the error is (regardless if positive or negative).
I am plotting using:
# line styles
set style line 1 lc rgb '#B2182B' # red
set style line 2 lc rgb '#D6604D' # red-orange
set style line 3 lc rgb '#F4A582' #
set style line 4 lc rgb '#FDDBC7' # pale orange
set style line 5 lc rgb '#D1E5F0' # pale blue
set style line 6 lc rgb '#92C5DE' #
set style line 7 lc rgb '#4393C3' # medium blue
set style line 8 lc rgb '#2166AC' # dark blue
# palette
set palette defined ( 0 '#B2182B',\
1 '#D6604D',\
2 '#F4A582',\
3 '#FDDBC7',\
4 '#D1E5F0',\
5 '#92C5DE',\
6 '#4393C3',\
7 '#2166AC' )
set dgrid3d 30,30 gauss 1
splot 'file.csv' matrix using 1:2:3 with lines palette title 'Error (%)'
I took the line styles and palette from ColorBrewer RdBu.
I tried also centering around zero using stats and set cbrange but without success.
"without success" is not sufficient description to debug. It should work to give the desired symmetric range as set cbrange [-foo : foo]". The numeric values given in the set palette` command are not important so long as they are symmetric. Here is an example
set palette defined (-1 "dark-red", 0 "grey90", 1 "dark-red")
set cbrange [-15 : 15]
set xyplane at 0
splot besj0(y)*x*x with pm3d

Using gnuplot to plot points with color and x-marks

I have been trying this for a few hours but I am not getting anywhere.
What I am trying to do is this:
I have a solution from a simulation with x and y values and a value for each point.
I am trying to plot the data using gnuplot. I want the values in between my data points to be interpolated using color and the points themself shall be marked with a dot, a "x" or sth. like that similar to this (except for the round border and those labels inside):
I have been trying to get a very basic example going. My data file looks like this:
1 1 0.1
1 2 0.3
1 3 0.6
2 1 0.5
2 2 0.7
2 3 0.9
3 1 0.2
3 2 0.8
3 3 0.7
and my gnuplot input like this:
set terminal postscript eps enhanced color font 'Helvetica,10'
set output './production/image1.eps'
set palette gray
set title "Titel"
#set xrange [1:4]
#set yrange [0:10]
set format y "%.1f"
set format x "%.1f"
set xlabel "x-Achse [Einheit]"
set ylabel "y-Achse [Einheit]" rotate by 90
set view map
set pm3d at b map
set pm3d interpolate 2,2
set dgrid3d 50,50,2
splot "inputDatei.dat" u 1:2:3 linecolor palette
The result looks like this:
There are a few issues with this which i cannot resolve:
there is a label in the rip right "inputDatai.dat" u 1:2:3". I tried splot ... label "" but this didnt solve the issue
the interpolation doesnt seem to work. this is visible with a smaller grid
the data points are not highlighted. I tried using splot ... with points but this would only display points at EVERY grid corner which is obviously way too much. Also the input data might not be "regular" but points can be anywhere.
I am very happy if someone could help me with this.
Greetings,
Finn
To your questions:
use unset key before the plot command or splot ... notitle within the plot command
what "does not work" mean? Please explain.
I guess that's similar to here (Superimposing vectors, dgrid3d and pm3d in gnuplot for 3D plot). You have to switch off interpolating for the highlighted points. I'm not sure whether this can be done within a plot command, so you have to plot the interpolated data into a separate datablock via set table and then switch off interpolation.
Code:
### interpolate data with highlighted datapoints
reset session
$Data <<EOD
1 1 0.1
1 2 0.3
1 3 0.6
2 1 0.5
2 2 0.7
2 3 0.9
2.5 2.5 0.1
3 1 0.2
3 2 0.8
3 3 0.7
EOD
set size square
set view map
set pm3d at b
set pm3d interpolate 2,2
set dgrid3d 50,50,2
set table $DataInterpolated
splot $Data u 1:2:3
unset table
unset dgrid3d
set palette grey
set xrange [0.9:3.1]
set yrange [0.9:3.1]
splot $DataInterpolated u 1:2:3 w pm3d palette notitle, \
$Data u 1:2:3 w p pt 1 lw 2 lc rgb "red" notitle
### end of code
Result:

Different scale for negative and positive values in y-axes - Gnuplot

Is it possible to plot a graph using different scale for negative and positive values in y-axes in Gnuplot?
I want to set the y range of the values in the y-axes from -2 to 70.
For values from 0 to 70 I want a scale e.g. 0,10,20,30,..70.
For values from 0 to -2 I want a different scale: 0, -0.1, -0.2, -0.3,..-2.
Thanks in advance.
Understanding your intention in general, I'm not sure whether the data you are providing are good enough to illustrate your desired outcome, so I have added two more data points where the negative y axis section is actually being used (see at the bottom of the post).
I used
multiplot to produce two separate plots, one for y values larger and one for those smaller than zero
the ternary operator (a ? b : c) to separate the date for each plot
I have done no work on the resulting graph, so it is extremely basic, and the large point size and different shape is only to "make the point". This is not a solution but should get you started:
# set up multiplot so that the two subgraphs are joined
set multiplot layout 2,1 margins 0.1,0.95,0.1,0.95 spacing 0
# no titles please
unset key
# we don't want tics for the upper half
unset xtics
plot[-2:2][0:70] "so.dat" using 2:($3>0?$3:NaN)\
w points pt 7 ps 2
# we do want xtics at the bottom
set xtics
plot[-2:2][-2:0] "so.dat" using 2:($3<0?$3:NaN)\
w points pt 5 ps 2
# cleanup
unset multiplot
reset
yields
My version of the data so.dat:
# TCP TFO
"Preparation" 1.126717 68.852979
"Establishment" -0.0436158 1.5529298
"Transfer" -0.1172298 0.5735358
"Interruption" 0.125 -1.25
"Execution" -1.5 -0.05
This has an answer already that has been accepted, but I have done some more work that I want to share; in particular,I wanted to have more control over the two subgraphs than the line
set multiplot layout 2,1 margins 0.1,0.95,0.1,0.95 spacing 0
allows. The lower subgraph should be visibly "thinner" than the upper one. Taking the opportunity, I also wanted to address Vladimir's question in his comment. So here we go:
### set up multiplot so that the two subgraphs are joined
set multiplot
# we need to set a left margin to keep the subgraphs aligned,
# and we need enough space for the ylabel
set lmargin 10
# no bottom margin, so that the second subgraph touches the upper one
set bmargin 0
# no titles please
unset key
# but we want a ylabel
set ylabel "Scales"
# no xtics
unset xtics
For Vladimir: see help set border
# we want left, top and right 2 + 4 + 8
# but no bottom border
set border 14
Now manually fix the area where we want to draw the first subgraph:
set size 1,0.5 # full with, half hight
set origin 0,0.5 # start at the left border, half way up
# optional: colour background
# set object 1 rect from -2,0 to 2,80 fc rgb "yellow" fillstyle solid .15 noborder
Ready to draw the graph:
plot[-2:2][0:80] "so.dat" using 2:($3>0?$3:NaN)\
w points pt 7 ps 2
The rest in one go:
# we do want xtics a label at the bottom
set xtics -2,.5,2 nomirror
set xlabel "Multiplot In Action"
set ylabel "Different"
set size 1,0.3 # full width, 30% of height, keep space for xlabel
set origin 0,0.2 # left, keep bottom 20% free
set tmargin 0 # no top margin, touch the upper subgraph
set bmargin 2 # for the xlabel
set border 11 # we want left, bottom and right border, no top 1 + 2 + 8
# set object 2 rect from -2,-2 to 2,0 fc rgb "blue" fillstyle solid .15 noborder
plot[-2:2][-2:0] "so.dat" using 2:($3<0?$3:NaN)\
w points pt 5 ps 2
# cleanup
unset multiplot
reset
This gives us
I would have liked the colour backgrounds, but the lower one is drawing over the dots in the upper one and I have not been able to fix that (back doesn't help).
Since gnuplot 5.2 you can define nonlinear coordinate systems with set nonlinear. This works similar to set link: You must provide a mapping function and its inverse for the axis you want to change.
In your case, the mapping function would scale all positive y-values and leave the negative ones unscaled:
RATIO=0.1
map(y) = y > 0 ? y*RATIO : y
inv_map(y) = y > 0 ? y/RATIO : y
set nonlinear y via map(y) inverse inv_map(y)
set xrange[-5:50]
plot x

Vector field 3D plot in gnuplot with contour of vectors (bottom)

I want to do a vector field plot with the vector arrows also depicted at the bottom just like in a surface contour plot using "set pm3d at b".
My file is given in the following format:
x y y dx dy dz
1 0 2 4 3 1
2 3 4 2 6 3
2 4 6 1 9 2
. . . . . .
I have used this gnuplot script:
set style arrow 1
set xrange[0.7:0.0]
set yrange[-0.4:0.4]
set zrange[-0.4:1.0]
set xtics (-0.7,-0.5,-0.33,-0.15,0.0,0.15,0.33,0.5,0.7) font "Times-Roman,18"
set ytics (-0.7,-0.5,-0.33,-0.15,0.0,0.15,0.33,0.5,0.7) font "Times-Roman,18"
unset ztics
set palette rgbformulae 30,31,32
set ticslevel 0
unset key
scale = 0.4
splot 'file.dat' u 1:2:3:($4*scale):($5*scale):($6*scale) w vectors arrowstyle 1
I also attached two 3d vector field plots with different views. What I actually want is a combination of both so that the contour of the plotted vectors should appear at the bottom (just like a top view using "set view 0,180" which is represented by the second image (top view) incorporated into the (side view) plot.
Vector_field_3d_plot_side_view
Vector_field_3d_plot_top_view
Since I havenĀ“t seen any gnuplot example for such a plot, I am not sure even if it is capable of doing it. If not, which software (Matlab, matplotlib,...) would you recommend me to use instead?
Thanks in advance!
I really appreciate any help!
Best wishes,
DaveS
Since you know the zrange, you can simply do the projection yourself and set z to the minimum value of the z-axis and dz to zero:
set style arrow 1
set xrange[0.7:0.0]
set yrange[-0.4:0.4]
set zrange[-0.4:1.0]
set xtics (-0.7,-0.5,-0.33,-0.15,0.0,0.15,0.33,0.5,0.7) font "Times-Roman,18"
set ytics (-0.7,-0.5,-0.33,-0.15,0.0,0.15,0.33,0.5,0.7) font "Times-Roman,18"
unset ztics
set palette rgbformulae 30,31,32
set ticslevel 0
unset key
scale = 0.4
splot 'file.dat' u 1:2:3:($4*scale):($5*scale):($6*scale) w vectors arrowstyle 1,\
'' u 1:2:(-0.4):($4*scale):($5*scale):(0) w vectors as 1

Draw front arrow over image

I have the following image using the code
set terminal png
set output 'plot.png'
set xlabel "GC (%)"
set ylabel "Proportion of genome"
set sample 1000
set xrange[0:100]
set yrange[0:]
set boxwidth 1
set style fill solid
set key off
set style line 1 lt 1 lc rgb "#0000FF" lw 3
set style line 2 lt 2 lc rgb "#32CD32" lw 3
Cauchy(x,xo,wi) = (1./pi) * wi / ((x - xo)**2 + wi**2)
plot 'compositionGC.txt' w boxes, 0.368187*Cauchy(x, 41.4226,1.72758) + 0.631813*Cauchy(x, 51.8272, 0.464711) ls 2
set yrange[0:GPVAL_Y_MAX]
set arrow from 47.2,0 to 47.2,GPVAL_Y_MAX front ls 1
replot
I have everything I need except that I want a vertical blue arrow separating the two peaks at 47.2 in the x-axis in the front. I cannot get it to work.
Do not change the yrange and replot.
Use this arrow command before the initial plot:
set arrow 1 from 47.2, graph 0 to 47.2, graph 1 front lc "blue"

Resources