kdensity normalised by the total number of points - gnuplot

I have the next plot of a KDE density plot of a dataset in file AAFPStable.dat which has 5 columns.
I only want to use the first for the plot.
set encoding iso_8859_1
set key right top font "Helvetica,17"
set ylabel "Density" font "Helvetica,18"
set xlabel "Minutes" font "Helvetica,18"
set xtics font "Helvetica,16"
set ytics font "Helvetica,16"
set title "Event 1" font "Helvetica, 18"
set size 1, 1.2
set terminal postscript eps enhanced
set grid
set key spacing 1.5
set key box linestyle 1 width 3
lfps = system("cat AAFPStable.dat | wc -l")
set output "event1-gnu.eps"
plot [0:150][] "AAFPStable.dat" using 1:(1) smooth kdensity bandwidth 2.5 lw 2 title "FPS"
The problem is that now the figure shows de KDE density plot but on the y-axis, it shows the number of occurrences. I would like to have the normalized density plot showing probability densities between 0 and 1. The command says that the second column should be 1/(count of points). The value of lfps is the number of rows of the file. I have tasted to change 1:(1) by 1:(1/lfps) but it does not work. I would not like to generate an intermediate file with the first column of AAFPS.dat and add a second with the value of 1/lfps.
How could I indicate gnuplot to plot the normalize KDE density plot?
Thank you for your help
Regards

It works with
plot [0:150][] "AAFPStable.dat" using 1:(1./lfps) smooth kdensity bandwidth 2.5 lw 2 title "FPS"
Thanks

Related

increase pixel size in gnuplot

As I said I have 2D matrix 68 per 68 and I want to make a heat map from it.
Each value in the matrix should be displayed as a separate cell. Every fourth cell should be labelled as "XXX\n715" 0, "XXX\n718" 3 and so on...
This is my plot: https://www.dropbox.com/s/tiipsn5mhmbnb5b/TEST.png?dl=0
Data used to produce this plot can be found here: https://www.dropbox.com/s/izrfbm157q1tedj/matrix.dat?dl=0
At present, I can see two problems with my plot:
1.) Cells are too small. Therefore, the plot is hard to read.
I want to increase size of a cell 2 times.
If I understand correctly, each pixel corresponds to one value?
If so, I would like to increase size of a pixel. That's way I was thinking
about drawing a grid size of 68*2/68*2, so that each value in my matrix will
be displayed in a 2-pixel/2-pixel-square box (cell).
2.) Values are outside cells's borders.
I had the same problem with smaller 2D arrays and I fixed it by trying
different resolutions (terminal size). I have been trying to apply a discussed
solution for the 68x68 matrix, but it did not work for me.
I tested many different scripts and I am stuck on these problems.
Thank you.
Code below:
set terminal png transparent truecolor nocrop enhanced size 800,800 font
"arial bold,8”
set output 'TEST.png'
set size ratio 1
set palette rgbformulae -21,-22,-23
# drawing grid
set x2tics 1 format '' scale 0,0.001
set y2tics 1 format '' scale 0,0.001
set mx2tics 2
set my2tics 2
# labels
set xtics 3 out nomirror
set ytics 3 out nomirror
set grid front mx2tics my2tics lw 0.5 lt 1 lc rgb 'black'
set xrange[-0.5:67.5]
set yrange[-0.5:67.5]
set x2range[-0.5:67.5]
set y2range[-0.5:67.5]
set xtics add ("XXX\n715" 0, "XXX\n718" 3)
set ytics add ("XXX\n715" 0, "XXX\n718" 3)
plot "matrix.dat" matrix w image noti

Adjusting position of individual plots in gnuplot multiplot

I am using multiplot to plot four graphs. My code is given below
set term postscript eps enhanced color
set pm3d map
set pm3d corners2color c1
set size square
set out 'defect2.eps'
unset colorbox
set colorbox horiz user origin 0.1,0.7 size 0.8,0.02
set cbrange [-1.6:0]
set xtics 25
set ytics 25
set lmargin at screen 0.1
set rmargin at screen 0.9
set multiplot layout 1,4
set xlabel "i" font "Times-italic,20"
set ylabel "j" font "Times-italic,20"
spl 'defect.dat' notitle
unset ylabel
spl 'defect_2.dat' notitle
spl 'defect_3.dat' notitle
spl 'defect_4.dat' notitle
unset multiplot
set out
This produces a following plot
However, individual plots in the picture are not properly placed. I cannot see ylabel for the first plot as it is hidden behind the screen whereas there are large blank gaps between those plots. Is there any way to reduce these gaps, increase size of these plots and show the labels properly?
Thanks in advance.
The Problem is your margin setting. The margin defines the size of the white stripe between the box containing the plot and the border of the window.
This means, tic and axis labels are printet on the Martin area! And your 10% of window width is not enough, so the labels are clipped.
So you can adjust the margins to shift all plots more to the left or adjust label font sites and offsets (Miguel's comment).

how to change gnuplot's graph size

I am trying to plot a graph with increased font size in gnuplot. A typical example is:
p sin(x) w l lw 5
set border lw 4
set tics font "Halvetica Bold,20"
So, I am trying to have:
adjust plot size without changing the canvas size to accommodate x/y label and tics
to adjust space between tics and label
How can I achieve this?
Kindly help.
The margins and the label positions depend on the total font size. You can specify this as part of the set terminal command.
The following script gives good margins and label positions:
set terminal wxt font ",20"
set border lw 4
plot sin(x) lw 5
For your example, you could adjust the margins with set lmargin ... and similar commands, and adjust the tic offset with set xtics offset ...:
set terminal wxt
set border lw 4
set tics font "Halvetica Bold,20"
set bmargin 3
set lmargin 10
set xtic offset 0,-1
set ytics offset -0.5,0
plot sin(x) lw 5

Plotting data vertically with gnuplot

I have a data file with a single column of data. By default, gnuplot renders this on the x-axis from left to right. However, I want to plot this data vertically from top to bottom. How can I do this?
The relevant excerpt from my plot file:
set size 1.0, 1.0
set terminal postscript eps enhanced color dashed lw 1 "Helvetica" 14
set output "ocean-diffuse.eps"
set autoscale
set xtic auto
set ytic auto
plot '0000086400.dat' using 1 with line, \
'0000172800.dat' using 1 with line
In order to have the single column used as x-value, use:
plot '0000086400.dat' using 1:0
That uses the row number (column 0) as y-values. Of course you can do any scaling and computation with the row number as
f(x) = x
plot '0000086400.dat' using 1:(f($0))
To have the y-axis reversed, use
set yrange [*:*] reverse

gnuplot Title and Axis labels are cut of by half

Ive changed the font size of the Graph title and the x and y axis label to the double size. Now the title and axis labels are much bigger but they are cut of by half and reach into the graph itself.
Is there an option to set a margin for the title so they are plotted complete and without reaching into the graph?
// Im using gnuplot 4.6 patchlevel 0
The label position and the margins are calculated based on the overall terminal font size, which can be set with set terminal or set termoption font ',20'.
So if you increase the font size locally (only for the title and axes labels), the margins and the label positions are wrong.
You can set explicit margins like set lmargin 5, which reserves a left margin corresponding to 5 character widths, or even absolute margins with e.g. set lmargin at screen 0.1. For title and xlabel there is an offset option, which allows to adjust the label position relative to the default position.
set terminal pngcairo size 600,400 font ',10'
set output 'output.png'
set xlabel 'xlabel' font ',30' offset 0,-1
set bmargin 5
plot sin(x)

Resources