IFPR-Labtelecom: Linux (Gnuplot)

Gnuplot permite a plotagem de gráficos por linha de comando, sendo útil em scripts e utilizados por outros programas externos para a geração de gráficos. Alguns projetos como o CMS - Nuvem utilizam o gnuplot para apresentação dos resultados, alguns comandos úteis e exemplos utilizados são apresentados nessa página.

Colocar título do eixo x em 45 graus:

set xtic rotate by -45 scale 0

Colocar legenda do gráfico na esquerda:

set key top left

Colocar legenda do gráfico abaixo e fora da região de plotagem:

set key outside bottom horizontal

Editar eixo X para inserir infomação de tempo:

set xdata time; set timefmt '%Y/%m/%d'; set format x '%m/%d';

Plotar figura em arquivo file.png com tamanho 750 x 440:

gnuplot -e "set terminal png size 750,440; plot 'dados.txt' using 1:2 title 'LEGENDA' " > file.png;

Exemplos:

Plotagem com barras - dispositivos conectados no Labtelecom:

cd /home/cluster; gnuplot -e "set title 'IFPR - Labtelecom'; set xlabel '' offset 0,0; set ylabel 'Quantidade de dispositivos conectados' offset 2,0; set terminal png size 750,440; set style data histograms; set yrange [0:100]; set ytics 10; set style histogram clustered gap 0; set style fill solid border;set boxwidth 1;set autoscale xfix; set xrange [0:21];set xtic rotate by -50 scale 1 offset 1,0.2; set linetype 1 lw 2 lc rgb 'black'; set linetype 2 lw 2 lc rgb 'green'; set linetype 3 lw 2 lc rgb 'red'; set timestamp; set grid; set terminal png size 750,440; plot 'Network_buffer.txt' using 7:xtic(1) notitle fill solid 0.2 border 1 ,'Network_buffer.txt' using 0:7:7 notitle with labels center offset 1.65,0.4 font ',9'" > log_network_clients_labtelecom.png;

Plotagem com barras - dispositivos conectados na Sala Eixo - 307:

cd /home/cluster; gnuplot -e "set title 'IFPR - Eixo Inf. sala 307'; set xlabel '' offset 0,0; set ylabel 'Quantidade de dispositivos conectados' offset 2,0; set terminal png size 750,440; set style data histograms; set yrange [0:100]; set ytics 10; set style histogram clustered gap 0; set style fill solid border;set boxwidth 1;set autoscale xfix; set xrange [0:21];set xtic rotate by -50 scale 1 offset 1,0.2; set linetype 1 lw 2 lc rgb 'black'; set linetype 2 lw 2 lc rgb 'green'; set linetype 3 lw 2 lc rgb 'red'; set timestamp; set grid; set terminal png size 750,440; plot 'Network_buffer.txt' using 6:xtic(1) notitle fill solid 0.2 border 1 ,'Network_buffer.txt' using 0:6:6 notitle with labels center offset 1.65,0.4 font ',9'" > log_network_clients_eixo307.png;

Plotagem com histograma - dispositivos conectados nos pontos de acesso wireless:

cd /home/cluster; gnuplot -e "set title ''; set xlabel '' offset 0,-1; set ylabel 'Quantidade de dispositivos conectados'; set terminal png size 750,440; set key outside top center horizontal; set style data histograms; set yrange [0:500]; set ytics 25; set style histogram clustered; set style fill solid border;set boxwidth 0.9; set style histogram clustered gap 1; set autoscale xfix; set xtic rotate by -50 scale 1 offset 0,0.2; set linetype 1 lw 2 lc rgb 'black'; set linetype 2 lw 2 lc rgb 'green'; set linetype 3 lw 2 lc rgb 'red'; set timestamp; set grid; set terminal png size 750,440; plot 'Network_buffer.txt' using 2:xtic(1) title'IFPR-ALUNOS 307' fill solid 0.4 border 1 , 'Network_buffer.txt' using 3 title'IFPR-ALUNOS 303' fill solid 0.4 border 1, 'Network_buffer.txt' using 4 title'IFPR-ALUNOS 305' fill solid 0.4 border 1" > log_network_clients_histogram.png;

Plotagem com linhas - temperatura dos equipamentos:

cd /home/cluster; gnuplot -e "set title ''; set key top right horizontal; set xlabel 'Tempo - Mês/Dia - Hora:Minuto' offset 0,-1; set ylabel 'Temperatura [{}^{o}C]'; set terminal png size 750,440; set xdata time; set timefmt '%Y/%m/%d-%H:%M'; set yrange [0:100]; set ytics 10; set style data lines; set autoscale xfix; set linetype 1 lw 2 lc rgb 'red'; set linetype 2 lw 2 lc rgb 'green';set linetype 3 lw 2 lc rgb 'blue';set linetype 4 lw 2 lc rgb 'black';set linetype 5 lw 2 lc rgb 'orange';set linetype 6 lw 2 lc rgb 'red'; set timestamp; set grid; set terminal png size 750,440; plot 'FsP_temperature_24h.txt' i 0 using 1:4 title'ARD A - Roteador 1921(in)','FsP_temperature_24h.txt' i 0 using 1:5 title'ARD A - Roteador 1921(out)','FsP_temperature_24h.txt' i 0 using 1:2 title'ARD B - FsP (processador)','FsP_temperature_24h.txt' i 0 using 1:3 title'ARD C - Multilayer 3560','FsP_temperature_24h.txt' i 0 using 1:6 title'Temperatura - Curitiba (PR)'" > FsP_temperature_24h.png;

Plotagem com linhas e barras - uptime dos equipamentos:

gnuplot -e "set title ''; set key top center horizontal outside; set xlabel 'Tempo - Mês/Dia' offset 0,-1; set ylabel 'Quantidade de dias'; set yrange [0:150]; set terminal png size 750,440; set xdata time; set timefmt '%Y/%m/%d'; set style data histeps; set autoscale xfix; set linetype 1 lw 2 lc rgb 'blue'; set linetype 2 lw 2 lc rgb 'black'; set ytics 15; set timestamp; set grid; set terminal png size 750,440; plot 'Uptime_buffer.txt' using 1:2 title'Amanda Linux Server' w boxes fill solid 1 border 1, 'Uptime_buffer.txt' using 1:3 title'FailsafePi'" > Uptime.png;