I have data of CPU utilization from monitoring. Monitoring does not start at first second of minute, but Gnuplot starts vaules of X axis at beginning of this minute. And missing seconds are filled with gaps (before and after graph of data).
Is it able to start axis X with my data and no gap?
I can not use: set xrange [ "13:12:24.8" : "13:21:24.8" ] with first and last value of monitored range of time. Because I monitor it many times a day. And I want grid in graph every 1 or 2 minutes.
my data:
column 1 ... col 195
13:12:24.8 0.78061899
13:12:25.8 5.969546498
13:12:26.8 17.21257881
...
13:21:24.8 6.922475345
gnuplot script:
!/usr/bin/gnuplot
set terminal png size 1280,800
set output "CPU.png"
set title "CPU"
set xlabel "time"
set ylabel "%"
set xdata time
set timefmt "%H:%M:%S"
set format x "%H:%M:%S"
set format y "%10.0f"
set yrange [ 1 : 100 ]
set grid
#source file and collumns for axes x,y
#CPU collumns: User Time: 196 ; Proccessor Time: 195
plot "perfmon.txt" using 1:196 title "User Time" with lines, \
"perfmon.txt" using 1:195 title "Processor Time" with lines
Graph showing the gaps:
These "gaps" are caused by gnuplot's default behavior to extend axis ranges to the next full tic. To avoid this for the x-axis, use
set autoscale xfix
Related
First-timer with gnuplot. Essentially I'm interested in what the subject says. I already have a mechanism that works in terms of rendering the bars and I just want to add label-values on the top of each bar:
I have the following data in a file called 'data.dat':
1,Json,457054
2,MessagePack,685440
3,Cbor,1273723
I employ the following gnuplot configuration file 'plot.gp':
##
# file_path - path to the file from which the data will be read
# graphic_file_name - the graphic file name to be saved
# y_label - the desired label for y axis
# y_range_min - minimum range for values in y axis
# y_range_max - maximum range for values in y axis
# column_1 - the first column to be used in plot command
# column_2 - the second column to be used in plot command
##
# graphic will be saved as 800x600 png image file
set terminal png
# allows grid lines to be drawn on the plot
set grid
# setting the graphic file name to be saved
set output graphic_file_name
# the graphic's main title
set title "Comparison"
# since the input file is a CSV file, we need to tell gnuplot that data fields are separated by comma
set datafile separator ","
# disable key box
set key off
# label for y axis
set ylabel y_label
# range for values in y axis
set yrange[y_range_min:y_range_max]
# to avoid displaying large numbers in exponential format
set format y "%.0f"
# vertical label for x values
set xtics rotate
# set boxplots
set style fill solid
set boxwidth 0.5
# plot graphic for each line of input file
plot for [i=0:*] file_path every ::i::i using column_1:column_2:xtic(2) with boxes
And I run the following gnuplot command:
gnuplot \
-e "file_path='data.dat' " \
-e "graphic_file_name='output.png' " \
-e "y_label='y' " \
-e "y_range_min='0000000'' " \
-e "y_range_max='1500000' " \
-e "column_1=1 " \
-e "column_2=3 " \
plot.gp
I can't figure out how to use 'with labels' at the bottom of the .gp file. Any help appreciated.
Here is yet another example. There is no need to do it in a for loop. You can use the pseudocolumn 0 (check help pseudocolumns) and lc var (check help linecolor variable) for setting the color.
Code:
### plot with boxes and labels
reset session
$Data <<EOD
1,Json,457054
2,MessagePack,685440
3,Cbor,1273723
EOD
set datafile separator comma
set style fill solid 0.3
set key noautotitle
set xrange[0.5:3.5]
set yrange[0:]
set format y "%.0f"
set grid x,y
set boxwidth 0.8 relative
plot $Data u 1:3:($0+1):xtic(2) w boxes lc var, \
'' u 1:3:3 w labels offset 0,0.7
### end of code
Result:
Hi to whole stackoverflow group,
I am having a series of problems when defining the axes range in my graphic
and format in general, and I would like to share it with you to see if among all we can find the error
I have found on this website a user who has made it similar. My idea is to have something similar like the graphic of the link below. But for some reason, it's probably silly, it does not appear correctly.
My code is as following:
set term post eps enhanced color "Times-Roman" 14
set output "ComparacionPurezaMetodos.eps"
set key off
set style data histogram
set style histogram cluster gap 1
set style fill solid border -1
set boxwidth 0.8
set xtic rotate by 90 scale 0
unset ytics
set y2tics rotate by 90
set y2label 'Ti_3SiC_2 content, wt{/Symbol\045}' offset -2.5
#set xlabel ' '
set size 0.6, 1
set label 'Powder mixture' at graph 0.5, -0.1 centre rotate by 180
plot 'datos.txt' using 1:(-1):3 with labels rotate right, 'datos.txt' using 1:2 with boxes
and the data are very simple:
# index, purity, name
1 98 Ti/Si/TiC
2 94 Ti/TiSi_2/TiC
3 93.6 Ti/Si/C
4 92 Ti/SiC/TiC
5 93 Ti/SiC/C
6 98 Ti/Si/C + Al
and I expect an output image like figure 4 (pag 6) of chapter 1 of this link:
https://books.google.es/books?id=zNWeBQAAQBAJ&printsec=frontcover&hl=es#v=onepage&q&f=false
But my output file does not have to do with this image.
Any idea / help?
Thanks in advance.
For your data, you don't need a histogram. Horizontal bars are sufficient. Instead of rotating a graph with plotting style with boxes you can use the plotting style with boxxyerror.
Make sure that your data separator is TAB or put your labels into "...".
### horizontal bars
reset session
set colorsequence classic
set datafile separator "\t"
$Data <<EOD
# index, purity, name
1 98 Ti/Si/TiC
2 94 Ti/TiSi_2/TiC
3 93.6 Ti/Si/C
4 92 Ti/SiC/TiC
5 93 Ti/SiC/C
6 98 Ti/Si/C + Al
EOD
unset key
set xlabel "Ti_2SiC_2 content, wt%" enhanced
set xrange [90:100]
set ylabel "Powder mixture"
unset ytics
set yrange [0:7]
set style fill solid 1.0
plot $Data u 2:1:(0):2:($1-0.4):($1+0.4):1 with boxxyerror lc variable,\
'' u 2:1:3 with labels offset 1,0 left
### end of code
Result:
When I plot with image in gnuplot, the label that I set is not displayed. Everything else is correct. Here is my code:
#! /bin/sh
#
# Plotting the color map of correlation using the default Matlab palette
#
gnuplot <<EOF
reset
set terminal pngcairo size 700,524 enhanced font 'Verdana,10'
unset key
# border
set style line 11 lc rgb '#808080' lt 1
set border 3 front ls 11
set tics nomirror out scale 0.75
set xrange [0:20]
set yrange [0:20]
set xlabel 'Distance x/D_j [-]'
set ylabel '{/Symbol t} u_j/D_j [-]'
# disable colorbar tics
set cbtics scale 0
# matlab palette colors
set palette defined ( 0 "#000090",\
1 "#000fff",\
2 "#0090ff",\
3 "#0fffee",\
4 "#90ff70",\
5 "#ffee00",\
6 "#ff7000",\
7 "#ee0000",\
8 "#7f0000")
set output 'test.png'
set label 'aaa' at 2,17
plot 'Cuup_nf_a090_r050Dj_average' u 1:2:3 with image
EOF
What is strange is: if I plot the data file using a column which doesn't exist as the third data series, for example:
plot 'Cuup_nf_a090_r050Dj_average' u 1:2:4 with image
(I have only 3 columns in the file 'Cuup_nf_a090_r050Dj_average')
Sure, I get only blank (no data) in my image, but the label is displayed correctly.
So it seems that the label is covered by my data palette... I have tried to put 'set label' at the end of code, but it doesn't work either.
Does someone have an idea?
ps: my gnuplot version: Version 4.6 patchlevel 4
Thanks a lot in advance.
Labels have an option front|back to position them on the front or back layer. Default setting is back, so that labels not specifying an explicit layer are hidden when plotting with image:
$data <<EOD
1 2
3 4
EOD
set label 'default, hidden' at graph 0.6, graph 0.7 font ",20"
set label back 'back, hidden' at graph 0.6, graph 0.5 font ",20"
set label front 'front, visible' at graph 0.6, graph 0.3 font ",20"
plot $data matrix with image
I am using gnuplot in version 5.0 in order to plot graphs from Log files which are received from another script. Initially, a script runs which creates the Log files, and inside the same script (upon finishing) a new script which will plot the graphs is executed by receiving some command line arguments.
One of the command line argument for the plotting graph script ($4 specifically) is the path where the data (which will be used by plot command) is located. Upon finishing of execution:
line 0: warning: Cannot find or open file "/comperative_data.txt"
where the command line argument is not used at all. See the source code of the script below:
gnuplot<<EOF
set size 1.0,1.0;
set terminal postscript landscape color "Times-Roman" 14 linewidth 2
set timestamp "%d/%m/%y %H:%M"
set key left top Left noreverse enhanced box linetype -1 linewidth 1.000 sample 4 spacing 1 width 0 height 0 autotitles
set grid back lt 0 lw 1
set xlabel "TCP Window Size (Bytes)"
set ylabel "Average Transfer Speed (KiB/s)
set xtics (131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432)
set xtics rotate
set logscale x
set format x "%10.f"
set yrange [0:5000000]
set output "$filename"
set title "$title"
fileLocation=system("echo $4/comperative_data.txt")
plot fileLocation using 1:2 title 'Streams_1' with linespoints, fileLocation using 1:3 title 'Streams_2' with linespoints , fileLocation using 1:4 title 'Streams_4' with linespoints , fileLocation using 1:5 title 'Streams_8' with linespoints , fileLocation using 1:6 title 'Streams_16' with linespoints , fileLocation using 1:7 title 'Streams_32' with linespoints , fileLocation using 1:8 title 'Streams_64' with linespoints
EOF
I want to create a histogram of a file that contains :
1 144 12.54
2 564 02.34
3 231 01.23
4 452 07.12
and what I use for that purpose in my script is :
gnuplot << EOF
set terminal gif
set terminal postscript eps color enhanced
set output "diagramma";
set title 'Diagramma'
set key off
set style data histogram
set style histogram cluster gap 1
set style fill solid border -1
set boxwidth 0.9
set autoscale
set xlabel "May"
plot 'finalsumfile' using 1:2 with histogram, 'finalsumfile' using 1:3 with histogram
EOF
So I want the first column as x coordinate and the second and third columns as y.
BUT when I run my script occurs this error:
line 0: Too many columns in using specification
What am I doing wrong?
try:
plot 'finalsumfile' using 2:xticlabels(1) with histogram
Histograms typically only take 1 column of data, which the "x-value" being implicitly incremented by one each time starting from 0. To set explicit x labels, you need to use xticlabels which takes the string in the given column and uses that as the label.