I use gnuplot for plotting data from 4 files on a single graph (png).
I get the 4 plots as different colored lines.
I want them to be of different line types so that the plot can be easily recognized in a black and white print out.
How to do that ? Many thanks for your help.
So what I want is http://gnuplot.sourceforge.net/demo/lines_arrows.html : Second figure. In Gnuplot, I get the plots as different colored lines.
Not entirely sure which detail of your question is the aspect you're struggeling with. When plotting from multiple files you specify this with plot 'FILENAME' using COLUMNS ... , 'FILENAME2' using COLUMNS ...
From the example you posted I see that the lines are black as long as lt -1 stays in. If you take it out, things become colorful. linespoints essentially connects the dots with lines, in the example that's pulled up to set style func linespoints which won't work here, as it's not a function which gets plotted.
Following the example you linked I suggest this:
set title ""
set xlabel ""
set bmargin 6
set offset .05, .05
set xrange [-0.5:3.3]
plot 'd1' using 1:2 lt -1 pt 6 ps 2 title 'pt 6' with linespoints,\
'd2' using 1:2 lt -1 pt 5 ps 2 title 'pt 5' with linespoints,\
'd3' using 1:2 lt -1 pt 7 ps 2 title 'pt 7' with linespoints,\
'd4' using 1:2 lt -1 pt 4 ps 2 title 'pt 4' with linespoints
where d1 looks like:
-0.5 0.8775825619
-0.4 0.921060994
-0.3 0.9553364891
-0.2 0.9800665778
-0.1 0.9950041653
0.0 1.0000000000
0.1 0.9950041653
0.2 0.9800665778
0.3 0.9553364891
0.4 0.921060994
0.5 0.8775825619
0.6 0.8253356149
0.7 0.7648421873
0.8 0.6967067093
0.9 0.6216099683
1.0 0.5403023059
1.1 0.4535961214
1.2 0.3623577545
1.3 0.2674988286
1.4 0.1699671429
1.5 0.0707372017
1.6 -0.0291995223
1.7 -0.1288444943
1.8 -0.2272020947
1.9 -0.3232895669
2.0 -0.4161468365
2.1 -0.5048461046
2.2 -0.5885011173
2.3 -0.6662760213
2.4 -0.7373937155
2.5 -0.8011436155
2.6 -0.8568887534
2.7 -0.904072142
2.8 -0.9422223407
2.9 -0.9709581651
3.0 -0.9899924966
3.1 -0.9991351503
3.2 -0.9982947758
3.3 -0.9874797699
EDIT:
thanks for clarifying. A few more pointers
Colors themselves: I recommend http://colorbrewer2.org/ to pick colors which are "photocopy safe". These tend to be well distinguishable even if printed in grayscale.
Markers: with the point type e.g. pt 5 you can specify different markers for the data. I changed the size with ps 2 in the above example. Especially open and filled markers are easily distinguishable from each other.
Linestyle: you need version 5 of gnuplot:
New features in version 5
* The dot-dash pattern of a line can now be specified independent of other
line properties. See dashtype
(p. 37), set dashtype (p. 115), set linetype (p. 135).
Without upgrading I couldn't get this to run, which is derived from the page you linked:
set termoption dash
unset colorbox
set title ""
set xlabel ""
set bmargin 6
set offset .05, .05
set xrange [-0.5:3.3]
show style line
plot 'd2' using 1:2 with linespoints dt 2 lw 3 lc rgb "black" ps -1,\
'd3' using 1:2 with linespoints dt 1 lc rgb "black" ps -1,\
'd4' using 1:2 with linespoints dt 3 lc rgb "black" ps -1
here dt is short for dash type, lw is line width, lc is line color which i set to black, ps is point style, disabled, so we don't see the points but only lines
Related
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:
I am trying to compare the results of a measurement from different collaborations using gnuplot. The plot should ideally look like this:
I can't figure out how to plot the different results one on top of the other, with the labels on the right. I would be really grateful if anyone could help me.
I show two approaches, depending of your data file. Two possible structures are data01.dat
# data01.dat
alpha error
1.0 0.2
2.0 0.2
1.5 0.2
or data02.dat
# data02.dat
Collab alpha error
1 1.0 0.2
2 2.0 0.2
3 1.5 0.2
Using the data01-structure:
reset
set encoding utf8
set terminal wxt size 480,600 font "Times New Roman,10"
set tics out nomirror
set xlabel "{/:Italic=12 α}"
set link y2
unset ytics
set y2range [:] reverse
set y2tics 1
set format y2 "Collaboration %g"
set offsets graph 0.1, 0.1, 0.5, 0.5
plot "data01.dat" u 1:0:2 w xerrorbars pt 7 not
Using the data02-structure almost all is the same, except the plot command.
plot "data02.dat" u 2:1:3 w xerrorbars pt 7 not
The results.
I hope be useful.
this is the first time that I use gnuplot . Therefore my question may be so obvious to solve but I could not figure it out. (I've already search on both stackoverflow and internet)
Now I need to plot number of dots on the plot and my file is like that:
dots-Xcoord dots-Ycoord Color_of_dot
> example:
1.1 0.234 "black"
2.15 3.1 "black"
1.76 0.94 "black"
3.15 6.12 "blue"
3.66 2.14 "blue"
So, to draw these dots on the graph I typed the following commands( non of them worked):
plot 'test.dat' using 1:2:3 with points pointtype 7 pointsize 1 lc variable
plot 'test.dat' using 1:2:3 with points pointtype 7 pointsize 1 lc 3
However when I type the command like that: plot 'test.dat' using 1:2 with points pointtype 7 pointsize 1 lc "black" It works. So my question is that how could I assign color of a dot from a file?
For change the color, you have to write rgb before the color:
plot 'test.dat' using 1:2 with points pointtype 7 pointsize 1 lc rgb "black"
or even:
plot 'test.dat' using 1:2 with points pointtype 7 pointsize 1 lc rgb "#FF0000"
by writing any color hex (just google the code of the color you want to)
I have 2 sets of data A and B, each with a y value for x=100, 200, 300. I want to create one graph which shows the difference between these two data sets. As such this means that for each x, there will be two boxplots(one for data A and one for data B).
for example, this is how the columns are organized in my data.
DataSet A
# x=100 200 300
1 2 3
1.1 2.1 3.1
1.2 2.2 3.2
1 2 3
1.01 2.01 3.01
DataSet B
# x=100 200 300
6 7 9
6.1 7.1 9.1
6.2 7.2 9.2
6 7 9
6.01 7.01 9.01
I was able to get two graphs out of this data using:
set style fill solid 0.25 border -1
set style boxplot outliers pointtype 7
set style data boxplot
set xtics ('100' 1, '200' 2, '300' 3)
plot for [i=1:3] "A.txt" using (i):i notitle
plot for [i=1:3] "B.txt" using (i):i notitle
However, I am facing issues when combining it into one.
Please help.
If you want to have them stacked above each other (in case they don't overlap), then you can just combine the two plot into one with
plot for [i=1:3] "A.txt" using (i):i notitle,\
for [i=1:3] "B.txt" using (i):i notitle
If they can overlap, you may want to put them side-by-side with
set boxwidth 0.3
plot for [i=1:3] "A.txt" using (i-0.15):i notitle,\
for [i=1:3] "B.txt" using (i+0.15):i notitle
Just to give two example of how you could combine those plots.
How can I make clustered rowstacked bars in gnuplot? It know how to get a clustered bars, but
not a cluster of rowstacked bars. Thanks!
Edit: in a cluster, stacked bars should use different colors/patterns as well.
I'm not completely sure how to go about doing this, but, one idea is to make it so that the boxes are touching each other
`set boxwidth 1`
That doesn't quite get you a "clustered" look yet -- To get a clustered look, I think you'd need to insert a row (maybe column) of zeros...(I haven't sorted through that one in my head yet) into your datafile where you want a cluster break.
Of course, you wouldn't need to set the boxwidth either I suppose...clustered just depends on the breaking every once in a while...
If I understand the original post right, it should be easy to accomplish with gnuplot if you can preprocess your data to offset x coordinates of specific data series.
To illustrate the approach I will use the following data in 3 data series:
# impulse.dat
0.9 1
1.9 4
2.9 3
3.9 5
1.0 1
2.0 2
3.0 4
4.0 2
1.1 3
2.1 3
3.1 5
4.1 4
Here each series has x-coordinates shifted by .1. To plot it I choose impulses of width 10.
plot [0:5] [0:6] 'impulse.dat' ind 0 w imp lw 10, \
'impulse.dat' ind 1 w imp lw 10, \
'impulse.dat' ind 2 w imp lw 10
Edit: to combine this with Matt's suggestion to use boxes would definitely be better:
set boxwidth 0.1
set fill solid
plot [0:5] [0:6] 'impulse.dat' ind 0 w boxes,\
'impulse.dat' ind 1 w boxes, \
'impulse.dat' ind 2 w boxes
Following is the picture with impulses.