Reputation: 307
I have a file which contains two column data. when plotted, it looks like
Green line is showing mean. I want to show mean value on Y-axis. Is it possible? code:
set style data lines
set termoption enhanced
set term png
set title "17th oct"
stats 'data/17-10-2013' using 1:2 nooutput
set xdata time
set timefmt "%s"
set format x "%H"
set output "images/17_DB.png"
plot "data/17-10-2013" using 1:3 title " Data" , STATS_mean_y title " Mean"
Upvotes: 1
Views: 1675
Reputation: 48440
Here are three different options to display the value:
set term pngcairo enhanced
set output "images/17_DB.png"
set title "17th oct"
stats 'data/17-10-2013' using 1:2 nooutput
set xdata time
set timefmt "%s"
set format x "%H"
# first option
set ytics add (sprintf('%.1f', STATS_mean_y) STATS_mean_y)
# second option
set ytics add ('' STATS_mean_y)
set rmargin 3
set label left at graph 1.05,first STATS_mean_y sprintf('%.1f', STATS_mean_y)
set style data lines
# third option inside the key label
plot "data/17-10-2013" using 1:3 title "Data" , \
STATS_mean_y title sprintf("Mean = %.1f", STATS_mean_y)
Here some notes about the different options:
0
).set rmargin 2
and other coordinates).For a nicer x
-axis, you may want to add set autoscale xfix
, which gets you rid of the empty space on the right side.
Upvotes: 2