Three 2D maps in a single 3D graph in Gnuplot - gnuplot

Is there any way to construct three 2D maps (three heat maps) in a
single 3D graph in the Gnuplot? I have three datasets (in matrix form) to plot as 2D maps in a single 3D graph: the first data in the XY plane, the second in XZ, and the last one in YZ.
Thus I tried the (naive) code:
set multiplot
splot 'data_1' matrix u 1:2:3 w image
splot 'data_2' matrix u 2:3:1 w image
splot 'data_3' matrix u 3:2:1 w image
unset multiplot
but except for the 'data_1' map, all the others are out of scale.
There is any way to do this?

You have to give the splot command 4 pieces of information: the x, y, and the z coordinate, and the value for the color. For example, the script
set xyplane at -0.5
set xrange [-0.5:3.5]
set yrange [-0.5:3.5]
set zrange [-0.5:3.5]
set xtics 1
set ytics 1
set ztics 1
set view 55,110
unset key
splot "data.dat" matrix u 1:2:(-0.5):3 w image, \
"" matrix u 1:(-0.5):2:3 w image, \
"" matrix u (-0.5):1:2:3 w image
where data.dat is a data file in matrix format such as
1 2 3 2
4 5 6 5
7 8 9 8
4 5 6 5
gives the following output:

Related

Energy diagram with gnuplot

I have text files like this:
NumberOfOrbital\tIt'sEnergy
I want to plot it as a horizontal sticks with a number of orbital on a left. When I am trying to plot it, I get points of given energy and number of orbital on x axis. What should I do??
In the gnuplot console check help vectors and help labels. I assume you are looking for something like this:
Code:
### horizontal lines with vectors and with labels
reset session
$Data <<EOD
A 1.10
B 1.50
C 1.70
D 2.10
E 2.50
F 3.30
G 3.60
EOD
unset xtic
set offset 1,1,1,1
set key noautotitle
set ylabel "Energy / a.u."
plot $Data u (0):2:(1):(0) w vec lw 2 lc "red" nohead, \
'' u (0):2:1 w labels offset -1,0
### end of code
Result:

Gnuplot: draw error bars of data points outside plotting range

If I set a specific yrange and plot in a pdf terminal with this plot command:
plot "data.dat" u 1:4:5:6 w yerrorbars pt 6 ps 0.5 t "R_t"
errorbars that belong to data points outside the yrange, but end inside the yrange are not shown.
How do I force gnuplot to draw those. I already tried "set clip one/two"
The only workaround I found is to plot the data 3 times, once for the central point and once for each side of the error bar.
Use "-" as symbol for the errorbars and use their own "errorbars" to draw a line to the central point.
You could use multiplot to achieve this.
Set your plot to have zero margins, so the axes are on the border of the canvas, and switch of all tics and borders for the first plot.
Switch on the axes, tics etc. again, and do an empty plot that you set at the correct position using set size and set origin. You'll have to do some math to calculate the exact position.
#MaVo159, you can reduce it to plotting only twice by using with yerrorbars and with vectors (check help vectors). You need to set the proper arrow style, check help arrowstyle.
However, this works only for gnuplot>=5.2.3, for earlier versions there seems to be a bug which plots the arrowhead at the wrong side for some of the vectors extending the graph.
You nevertheless have to plot once with yerrorbars in order to get the proper legend.
Script: (works for gnuplot>=5.2.3, May 2018)
### plot errorbars from points outside the range
reset
$Data <<EOD
1 9 5.11 8.32
2 8 6.20 9.22
3 6 5.31 6.31
4 5 4.41 5.51
5 4 3.31 4.71
6 2.9 2.81 3.71
7 2 1.11 3.41
EOD
set yrange[3:7]
set offsets 1,1,0,0
set style arrow 1 heads size 0.05,90 lw 2 lc 1
set multiplot layout 2,1
plot $Data u 1:2:3:4 w yerrorbars pt 6 ps 2 lw 2
plot $Data u 1:2:3:4 w yerrorbars pt 6 ps 2 lw 2, \
'' u 1:3:(0):($4-$3) w vec as 1 notitle
unset multiplot
### end of script
Result:
You could modify your data file: Because the central value of the data point is outside the plot range you could set it equal to the errorbar's end point that would be still visible in your plot.
Example:
plot range: set yrange[-2:2]
data point: 1, -3, -1, -4 (x, y, ylow, yhigh)
set data point to: 1, -1, -1, -4
Attention: Since you have to edit your data file you should
Make a copy of the original data file
Be very careful when editing the file
Keep in mind, that when changing the plot range such that the central
value of the data point becomes visible you have to use the original data point. Otherwise you will see the correct error bar but there will be no central value plotted. (this is equivalent to setting 'point type' to 0)

Gnuplot histogram with errorbars (High and Low)

I am trying to create a histogram (barchart) with High and Low errors, using gnuplot. I have found this thread Gnuplot barchart histogram with errorbars Unfortunately it consists only from X value and X-error (2 vaues). Whats I would like to achieve is X value (average) and error bar consisting of High and Low values (total 3: avg, High and Low). How I can do this using gnuplot?
My script is identical to the one mentioned in the Thread, I only changed some labels etc (simple cosmetic changes). My example dataset structure is as follows:
WikiVote 10 12 7
If you have a very simple datafile:
#y ymin ymax
4 3 8
You can plot this datafile using:
set yrange [0:]
set style histogram errorbars gap 2 lw 1
plot 'datafile' u 1:2:3 w hist
I have modified the code provided by mgilson, to achieve multiple histograms for a single X value. If anybody needs it here is the code.
plot 'stack_2.dat' u 2:3:4:xtic(1) w hist ti "Hadoop" linecolor rgb "#FF0000", '' u 5:6:7:xtic(1) w hist ti "Giraph" lt 1 lc rgb "#00FF00"
Here is the pattern
#y_0 #min #max #y_1 #min #max
Dataset 4 3 8 6 5 9

How do I plot 2-dimensional data in circles where radius representing the 3rd column and the color representing the 4th column?

Here is an example data set.
#x y r c
1 2 10 2
3 1 2 4
3 2 1 5
I can plot with circle's radius representing the 3rd column OR with color representing the 3rd column. However, I don't know how to keep them both in the plot.
Here is my code to plot with radius representing the 3rd column.
plot 'rslt.log' u 1:2:3 w points pt 7 ps variable
Try:
plot 'rslt.log' u 1:2:3:4 w points pt 7 ps variable lc palette
An alternative is:
plot 'test.dat' u 1:2:3:4 w p pt 7 ps variable lc variable
or using the circles linestyle:
plot 'test.dat' u 1:2:3:4 w circles linecolor variable
If you want solid filled circles:
plot 'test.dat' u 1:2:3:4 w circles linecolor variable fillstyle solid
For any of the above, you can substitute linecolor variable with linecolor palette as suggested by #andyras. The difference is that palette maps a floating point number onto the palette whereas variable maps the integer to a linestyle which has a color associated with it.
With ps variable the number in the associated column becomes a multiplicative factor which increases the default size of the point. With circles you have the freedom to specify the exact size of the circle (as the radius) -- Although I'm not 100% sure which axis is used in the common case where the aspect ratio of your plot isn't 1.

setting multiple labels at the top of the x-axis

After the answer got in my earlier post drawing vertical lines in between bezier curves, I have been trying to label the segments separated by the dotted lines. I used x2label but found out that if I use it multiple times then the data gets replaced though they are positioned in different places. Below is the script:
set term x11 persist
set title "Animation curves"
set xlabel "Time (secs.)"
set ylabel "Parameter"
set x2label "Phoneme1" offset -35
set pointsize 2
set key off
set style line 2 lt 0 lc 1 lw 2
plot [0.04:0.15] "curve.dat" u 1:2 smooth csplines ls 1, "" u 1:($2-0.2):(0):(0.3) w vectors nohead ls 2, \
"curve.dat" u 1:2 with points
The output is the following.
I want to label Phoneme1, Phoneme2...and so on.. on top of each segment. How would I do it? Also as I was suggested in my earlier post to play with the line "" u 1:($2-0.2):(0):(0.3) w vectors nohead ls 2 to get a top to bottom vertical lines. But that also did not work. How do I get the lines from top margin to bottom? Thank you.
The horizontal lines
The horizontal lines can be accomplished with setting the yrange to an explicit value. Otherwise gnuplot would try to get some space between the lines and the axis. You could choose the values
set yrange [0.3:1.2]
Then you simply modify the vector using directions like so:
"" u 1:(0.3):(0):(1.2) w vectors nohead ls 2
(see below for the complete script)
The labeling of the sections
A quick way of doing this with your set of data would be this:
set key off
set style line 2 lt 0 lc 1 lw 2
set yrange [0.3:1.2]
plot [0.04:0.15] "Data.csv" u 1:2 smooth csplines ls 1, \
"" u 1:(0.3):(0):(1.2) w vectors nohead ls 2, \
"" u ($1+0.005):(1):(sprintf("P %d", $0)) w labels
However, this will probably not look the way you want it to look. You could think of modifying your data file to also include some information about the labeling like:
#x-value y-value x-label y-label label
0.06 0.694821399177 0.65 0.1 Phoneme1
0.07 0.543022222222 0.75 0.1 Phoneme2
Then the labels line would simply look like:
"" u 3:4:5 w labels
The complete plot then looks like this:

Resources