heatmap color not relating with data in gnuplot - gnuplot

I am trying to create one heatmap using Gnuplot and my data file structure is looked like below:
6 5 4 3 1 0
3 2 2 0 0 1
0 0 0 0 1 0
0 0 0 0 2 3
0 0 1 2 4 3
the cell values are z values and columns represent y-axis and row are x-axes. that means the first value 6 is the z value where the y-axis is 5th position at x label zero. However, while plotting the heat map I am getting a different color which does not correlate with the z value. Also, I am getting five bins for the x-axis (which is supposed to be 6)and 4 bins (which is supposed to be 5) for the y-axis. My simple code is written below:
set pm3d map
splot 'm.txt' matrix
Please help me out of this confused situation.
Thanks.

Related

How can I display data from 3 tables into a single table?

I have 3 datasets a,b,c and 3 tables that give values based on the strength of their relationships. a has 5 items, b has 7 items, and c has 4 items. (a,b)(a,c)(b,c). I am trying to find a way to display all the data from these tables in a single graphic. The axis would have a Y shape with each leg representing a different data set and the cells representing their relationship strength.
I have looked through excel charts and haven't found anything that might help represent this. Is there another program which would be better? Looking for something simple to use.
Below is an example of the 3 tables and the type of data they contain. I want a way to show the scores for each relationship in a grid.
Table 1
A
B
Score
1
x
3
2
x
5
3
x
0
1
y
2
2
y
6
3
y
0
1
z
5
2
z
8
3
z
0
Table 2
A
C
Score
1
blue
3
2
blue
8
3
blue
2
1
red
0
2
red
4
3
red
1
1
yellow
3
2
yellow
3
3
yellow
9
Table 3
B
C
Score
x
blue
2
x
red
1
x
yellow
5
y
blue
0
y
red
3
y
yellow
7
z
blue
0
z
red
1
z
yellow
3
Here is an example of what I am trying to do with the data
I manually created this type of visual in autoCAD
This works as a one-off but it doesn't scale and is very tedious. Hoping there is a programmatic way to create something similar.

Need help understanding MCNP TMESH tally output

I am trying to understand the the MCTAL output of a spherical TMESH tally. What I want is to create one tally bin that has the following boundaries 1.9 cm and 2.1 cm in the radial direction, 88 to 92 degrees in theta and 180 to 360 degrees in the phi direction. my input for the tally is
C tally card spherical mesh energy tally
TMESH
SMESH1:p DOSE 1 1 1 1.0 PEDEP MFACT 1 1 0 1.0
CORA1 1.9 2.1
CORB1 88 92
CORC1 180 360
Now what I expect is one result for that volume what I get are eight values as shown below.
ntal 1
1
tally 1 -1 -3
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
f 4 0 1 2 2
1.90000E+00 2.10000E+00
0.00000E+00 8.80000E+01 9.20000E+01
0.00000E+00 1.80000E+02 3.60000E+02
d 1
u 1
s 2
m 1
c 1
e 1
t 1
vals
5.57481E-04 0.0067 7.68088E-09 0.0493 8.24471E-03 0.0046 1.38395E-07 0.0639
5.53931E-04 0.0046 7.44313E-09 0.0287 8.24244E-03 0.0042 1.27868E-07 0.0553
I am assuming that these eight vals correspond to the eight points that that are listed under f. Does TMESH only give one values for individual points on a grid or can it be used to create a volume within which to obtain a result? lastly to what points do what vals correspond to ?
The matrix bellow the vals is true value of your meshtally result.
but
you must load data to Matlab and reshape it to your mesh tally matrix
With your SMESH setup you score both dose and energy deposition. This causes two bins along the segment axis (the "s 2" record in your mctal). Then, you have only 1 bin along the radial direction (1.9-2.1 cm) and actually TWO bins along each of the angular directions (0-88, 88-92, and 0-180, 180-360) which sums up to 2^3 = 8 bins. The mctal file format is described in the manual: it'a 11-dimension loop. In your case only the s, j and k axes are divided, so it's actully a 3D loop (in this exact order: s being the outer, k - the inner loop). Therefore the value for your volume is either the 4th (1.38395E-07 0.0639) or last (1.27868E-07 0.0553) record depending on whether you need dose or energy deposition.

Summing over y values for same x value

I want gnuplot to plot the sum of all z values in all cases where the x and y values are equal.
A dummy data file looks like this:
#testfile
0 0 1
0 1 1
0 1 1
0 1 1
1 0 1
1 1 1
1 1 2
1 1 2
I am using plot "testfile" u 1:2:3 w p ps variable to scale the points according to the value in the third column, and I would like to find a command that gives the same plot for the above data file as if I were to plot this data file:
#testfile2
0 0 1
0 1 3
1 0 1
1 1 5
If that makes it easier, in my real data file, I always have to sum over two lines.
I don't know if you're looking for a gnuplot-only solution, but what you want could be accomplished with a simple awk one-liner, either ran separate or embedded on gnuplot. By the way, this assumes that you you always have to sum over two lines:
Input file:
0 1 1
0 1 1
1 0 1
1 0 2
1 1 2
1 1 2
By running:
awk '{sum+=$3} (NR%2)==0{print $1,$2,sum; sum=0;}' testfile
You would get:
0 1 2
1 0 3
1 1 4
Then you could save in a separate file and plot with the line you mentioned above. Alternatively, you can embed the awk line within gnuplot using:
plot "<awk '{sum+=$3} (NR%2)==0{print $1,$2,sum; sum=0;}' testfile" u 1:2:3 not w p ps variable pt 7
Hope it helps!

How to build a scatter graph in excel with average y value for each x value

I am not sure that here is the best place to ask,
but I have summerized my program performance data in an excel file and I want to build a scatter graph.
For each x value I have 6 y values and I want my graph to contain the average of those 6 to each x.
Is there a way to do this in excel?
For example: I have
X Y
1 0.2
1 0
1 0
1 0.8
1 1.4
1 0
2 0.2
2 1.2
2 1
2 2.2
2 0
2 2.2
3 0.8
3 1.6
3 0
3 3.6
3 1.2
3 0.6
For each x I want my graph to contain the average y.
Thanks
Not certain what you want but suggest inserting a column (assumed to be B) immediately between your two existing ones and populating it with:
=AVERAGEIF(A:A,A2,C:C)
then plotting X against those values.
Or maybe better, just subtotal for each change in X with average for Y and plot that.

gnuplot | 3D layers

I have the below data file which has:
1st column is the layer number.
2nd column is the X axis.
3rd column is the Y axis.
1 1999-01-19 21 0 1
1 2009-07-01 0 1 1
1 2008-08-20 2 1 1
1 2008-12-18 1 1 1
2 2004-05-12 4 1 1
2 2009-07-29 2 1 1
3 2008-08-07 0 1 1
4 2006-03-08 1 1 1
4 2004-08-31 9 1 1
4 2001-03-27 12 1 1
My questions:
1. How can I plot the above data file in 3D knowing that each layer must have different Z offset and different color?
the below must be plotted with Z=1
1 1999-01-19 21 0 1
1 2009-07-01 0 1 1
1 2008-08-20 2 1 1
1 2008-12-18 1 1 1
and the below with Z=2
2 2004-05-12 4 1 1
2 2009-07-29 2 1 1
and so on.
2.If I want to select the layer number 2, other layers must be shaded with gray and this layer must be colored with red for example, is that possible? so it's like highlighting the selected layer.
thx.
To plot the points just use
set xdata time
set timefmt '%Y-%m-%d'
set format x '%Y'
splot 'data.dat' using 2:3:1
That uses the layer number as z-value. To get something else, just specify a function for the z-value depending on the layer number:
zpos(z) = 1 + 0.5*z
splot 'data.dat' using 2:3:(zpos($1))
For the coloring use linecolor rgb variable. That allows you to specify the color in the last column. This color must be the integer representation of an rgb-tuple which is 65536*red + 256*green + blue, with red, green and blue being in the range [0:255].
The following script plots the points in layer 2 in dark red:
set xdata time
set timefmt '%Y-%m-%d'
set format x '%Y'
rgb(r,g,b) = 65536*r + 256*g + b
gray = rgb(200,200,200)
red = rgb(200,0,0)
layer = 2
set view 66,20
splot 'data.dat' using 2:3:1:($1 == layer ? red : gray) with points pt 7 linecolor rgb variable notitle
The result with 4.6.4 is:

Resources