Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Gnuplot 4.6 bug? lines not being drawn

1,729 views
Skip to first unread message

marce...@gmail.com

unread,
Feb 23, 2013, 10:25:12 PM2/23/13
to
Hello,

I've just started using Gnuplot 4.6 this week. I am trying to plot only certain data. Here is an example:

plot 'data.txt' using 1:(stringcolumn(3) eq "a"? $2:1/0) notitle with lines


This works fine if I use "with dots", "with impules", etc. But it does not draw anything when I use "with lines" or "with steps".

Is this a known issue?

Thanks.

Hans-Bernhard Bröker

unread,
Feb 24, 2013, 12:06:27 PM2/24/13
to
On 24.02.2013 04:25, marce...@gmail.com wrote:

> plot 'data.txt' using 1:(stringcolumn(3) eq "a"? $2:1/0) notitle with lines

> This works fine if I use "with dots", "with impules", etc. But it
> does not draw anything when I use "with lines" or "with steps".

> Is this a known issue?

That's pretty impossible to tell without seeing at least a sample of the
actual data.

But do note that 'with lines' only connects consecutive points in your
data file. Blank lines interrupt the line, so it may be that your line
consists of nothing but interruptions, which would make it no line at all.

Karl

unread,
Feb 25, 2013, 7:04:50 AM2/25/13
to
Yes.

Lines are only drawn between consecutive points (try "with
linespoints"). One way out of this might be:

gp> plot "data" using (stringcolumn(3) eq "a" ? $1 : 1/0) : 2 \
smooth unique with lines

(haven�t tried, btw. ;-))

Smooth unique renders the data monotonic, so all the invalid points
(which are now invalid on x instead of y) should land outside of the plot.


Karl

marce...@gmail.com

unread,
Feb 25, 2013, 12:00:56 PM2/25/13
to
Thanks Karl. Unfortunately that didn't work either. Here is an example of my actual data:

02222013083723,ServerA,586950936,1709,20817,3.510409
02222013083723,ServerB,659800656,1702,20920,8.715981
02222013083724,ServerC,873737176,1745,21133,5.4260693
02222013083724,ServerD,1043938832,1716,20898,4.24047
02222013083745,ServerA,623933280,1682,20817,5.815545
02222013083745,ServerB,692769240,1674,20922,6.93751
02222013083745,ServerC,704775144,1704,21133,7.0087843
02222013083746,ServerD,731880448,1706,20898,6.9982367
02222013083806,ServerA,605951920,1609,20817,7.0428286
02222013083807,ServerB,753759440,1599,20937,4.6636114
02222013083807,ServerC,1140883088,1630,21133,5.761619
02222013083807,ServerD,926288920,1614,20899,7.0784245
02222013083828,ServerA,622904272,1601,20817,3.4892871
02222013083828,ServerB,756817136,1591,20937,8.244981
02222013083828,ServerC,1030568704,1622,21133,14.123659
02222013083828,ServerD,1120398200,1601,20902,4.7675056

There is a script that goes out to different servers and grabs some metrics. It then sends the data to a metrics file. In the case above, there are four servers. The last data point (6) is the CPU utilization. My goal is to create one graph with the CPU utilization of all 4 servers on it. A line graph would be perfect here.

This is what I use to plot ServerA CPU:
plot 'test.txt' using 1:(strcol(2) eq "ServerA"? $6:$1/0)

To plot all 4 CPU's, I would use:

plot 'test.txt' using 1:(stringcolumn(2) eq "ServerA"? $6:1/0) title "ServerA" ,\
'test.txt' using 1:(stringcolumn(2) eq "ServerB"? $6:1/0) title "ServerB" ,\
'test.txt' using 1:(stringcolumn(2) eq "ServerC"? $6:1/0) title "ServerC" ,\
'test.txt' using 1:(stringcolumn(2) eq "ServerC"? $6:1/0) title "ServerD"


This would create a graph with an different color of 'X' for each data point. This is difficult to see when you start adding more servers. Being able to draw one line for each server CPU would be great.

Is there any other way to do this? The plot command I used above is basically taken from an older post in a support group to plot filtered data. Maybe with Gnuplot 4.6, there is a different way to do this?


If you want to plot the data above yourself, use these parameters:

set xdata time
set format x "%H:%M"
set timefmt x "%m%d%Y%H%M%S"
set datafile separator ","

Christoph Bersch

unread,
Feb 25, 2013, 1:59:20 PM2/25/13
to
Am 25.02.2013 18:00, schrieb marce...@gmail.com:
>
> 02222013083723,ServerA,586950936,1709,20817,3.510409
> 02222013083723,ServerB,659800656,1702,20920,8.715981
> 02222013083724,ServerC,873737176,1745,21133,5.4260693
> 02222013083724,ServerD,1043938832,1716,20898,4.24047
> 02222013083745,ServerA,623933280,1682,20817,5.815545
>
> This is what I use to plot ServerA CPU:
> plot 'test.txt' using 1:(strcol(2) eq "ServerA"? $6:$1/0)

Try

plot '< grep "ServerA" test.txt' u 1:6 with lines

For the explanation see Hans-Bernhard's posting.

Christoph

Karl

unread,
Feb 25, 2013, 3:36:24 PM2/25/13
to
Tried now too, and it cannot work. H.-B. and Christoph are right, you�ll
have to sort or filter your data externally, using 'grep' or the like.

> The plot command I used above is basically taken from an older post in
a support group to plot filtered data.

Can you post that older post (or a link) ?
I wonder how they managed to make it work.


Karl

Marcelo Jara

unread,
Feb 25, 2013, 4:54:59 PM2/25/13
to
Well, it works without using "with lines".

Here's the post:
http://getthedata.org/questions/603/parsing-csv-data-into-gnuplot/




Hans-Bernhard Bröker

unread,
Feb 25, 2013, 5:39:17 PM2/25/13
to
On 25.02.2013 18:00, marce...@gmail.com wrote:

> There is a script that goes out to different servers and grabs some
> metrics. It then sends the data to a metrics file.

This would all be a _lot_ easier if you just kept the data from separate
servers in separate files. After all, what good does it do you to
collect all the data in a single file if all you ever do with that is
split it back up into individual streams?


Karl

unread,
Feb 26, 2013, 3:32:37 AM2/26/13
to
Am 25.02.2013 22:54, schrieb Marcelo Jara:
>
> Well, it works without using "with lines".
>
> Here's the post:
> http://getthedata.org/questions/603/parsing-csv-data-into-gnuplot/
>

"with lines" only connects points that are directly succeeding in the
order they are read from a data file, _before_ the evaluation of a
"using" statement. 1/0 does count as a data point, in that sense.

There is just no chance to get them to connect without external filtering.

One could think of defining a special value that, when read, makes
gnuplot skip the line _and_ connect the points before and after, but
that would be for the developers.

Karl

Marcelo Jara

unread,
Feb 26, 2013, 10:47:30 AM2/26/13
to

Thanks for everyone's help. Christoph's suggestion did work for me (using 'grep'). Here's the final statement:

plot '<grep "ServerA" test.txt' u 1:6 title "ServerA" with lines, \
'<grep "ServerB" test.txt' u 1:6 title "ServerB" with lines, \
'<grep "ServerC" test.txt' u 1:6 title "ServerC" with lines, \
'<grep "ServerD" test.txt' u 1:6 title "ServerD" with lines


I guess for Windows, I would need to change it to 'find', but haven't tested it yet.

There is no technical reason as to why I have the different servers' metrics in one file. I am responsible for stress testing applications and servers. When a test starts, I grab all the metrics for all the relevant servers. I stop grabbing the metrics when the test ends. For me, it was easier to have one file per test that represented all the performance metrics. Otherwise, I would have 8 or more files per test. There are definitely different ways to do this and could easily have written the metrics to separate files and then possibly join the files after using Gnuplot.

Thanks again.

0 new messages