nutim
nutim

Reputation: 167

using gnuplot for drawing multiple graphs

I have data like this

Date       instance 1, 2, 3, 4, 5, 6
03-09-2013 0 0 1 0 0 1
03-09-2013 0 0 6 0 0 6
03-09-2013 0 0 2 0 0 6
03-09-2013 0 0 3 0 0 6
03-09-2013 0 0 1 0 0 6
03-09-2013 0 0 2 0 0 6
04-09-2013 0 0 4 0 0 4
04-09-2013 0 0 8 0 0 8
04-09-2013 0 0 2 0 0 8
04-09-2013 0 0 3 0 0 4
04-09-2013 0 0 1 0 0 8
04-09-2013 0 0 5 0 0 8

It is just sample of huge data. For every day there are 6 columns, shows the 6 difference process instances.

I have to pick maximum number of instances for each day and plot it on graph.

like on 03 Sep for process 3 there are 6 instances, on 4 sept there are 8 instances like that i have to pick maximum number of instances for each date and plot a graph with 6 different lines depicting instances for each process.

Problem: I am writing code in Shell script, how do i get maximum number of instances for each process for each day. Is there a way to build data structure and find out. Or Do I need to use Python or Perl? if so, please guide. All these scripting languages are completely new to me.

2) How do I plot using gnuplot. example

03-09-2013 2 0 2 3 0 7
04-09-2013 6 0 4 2 0 12
05-09-2013 7 0 6 1 0 14

My graph should have dates in X-Axis, no. of process in Y-Axis. each line for each instance, 6 lines for 6 instances.

Upvotes: 1

Views: 543

Answers (1)

andyras
andyras

Reputation: 15910

I can answer the second question (more information is needed for the first part).

With a data file like

03-09-2013 2 0 2 3 0 7
04-09-2013 6 0 4 2 0 12
05-09-2013 7 0 6 1 0 14

You can plot it with

set xdata time
set timefmt "%m-%d-%Y"
plot for [ii=1:6] 'data.dat' using 1:ii title 'Instance '.ii

Or replace the plot for with something like

plot 'data.dat' using 1:2 title 'Instance 1', \
'data.dat' using 1:3 title 'Instance 2', \
'data.dat' using 1:4 title 'Instance 3', \
'data.dat' using 1:5 title 'Instance 4', \
'data.dat' using 1:6 title 'Instance 5', \
'data.dat' using 1:7 title 'Instance 6'

Upvotes: 2

Related Questions