LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-28-2017, 03:48 AM   #1
prompt32
LQ Newbie
 
Registered: Oct 2013
Location: Greece
Posts: 7

Rep: Reputation: Disabled
gnuplot - plot with loop problem


hello, i have a problem with a gnuplot script, and i cant figure out what the problem is ....


my data file, have the following format, (values are as example)
Code:
# timestamp        |- user1 -|       |-user2-|          |-user3-|
# ms            procs cpu% mem%   procs cpu% mem%    procs cpu% mem%
1234            10    12   13       20   22   23      30    32   33
1235            19    15   16       29   25   26      39    35   36
my gnuplot code is
Code:
reset

USERS="user1 user2 user3"

VAL(g,c)= (3*(g-1)) + c  

plot for [i=1:words(USERS)] "__GCRONDIR__/.data/usrstat.log" \
   u 1:VAL(i,3) t word(USERS,i)." cpu:".i  __STYLE0__, \
"" u 1:VAL(i,4) t word(USERS,i)." mem:".i  __STYLE0__
my problem is that the loop, happens only for the last user,
so if a have 10 users, lets say, this script, will plot 9 cpu's values,
for the first 9 users, and both values for the last one.
... for me make no sense, any one ?

here a screen shot


Click image for larger version

Name:	170728-114624_root@ohost3.jpg
Views:	23
Size:	58.3 KB
ID:	25589

Last edited by prompt32; 07-28-2017 at 04:56 AM.
 
Old 07-28-2017, 09:56 AM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
I do not totally understand this , but is it zero based? you maybe missing that 0 = 1, 1 = 2, 2 = 3, etc... in zero based. That maybe why you're only showing 9 out of 10.

Last edited by BW-userx; 07-28-2017 at 09:58 AM.
 
Old 07-28-2017, 12:02 PM   #3
prompt32
LQ Newbie
 
Registered: Oct 2013
Location: Greece
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by BW-userx View Post
I do not totally understand this , but is it zero based? you maybe missing that 0 = 1, 1 = 2, 2 = 3, etc... in zero based. That maybe why you're only showing 9 out of 10.

taking for my example above, gnuplot will plot
Code:
user1 cpu
user2 cpu
user3 cpu
user3 mem
and NOT
Code:
user1 cpu
user1 mem
user2 cpu
user2 mem
user3 cpu
user3 mem
as i expect. I mean, both values plotted only for the last user, in the example 'user3'.
I have the 'same' script for my net interfaces, that plot the IN/OUT traffic. It happens to be 5-7 interfaces, and only to the last one i get what i plan to. .... ?
 
Old 07-28-2017, 01:40 PM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
so 2 curves per user?

still I am just guessing here.

docs examples
Code:
A plot with filled area between two given curves can be easily obtained using the pseudo file ’+’ with filledcurves closed. The example below demonstrates this for two curves f(x) and g(x):
f(x)=cos(x)  
g(x)=sin(x)  
xmax=pi/4  
set xrange [0:xmax]  
plot ’+’ using 1:(f($1)):(g($1)) with filledcurves closed
Code:
USERS="user1 user2 user3"

VAL(g,c)= (3*(g-1)) + c  

plot for [i=1:words(USERS)] "__GCRONDIR__/.data/usrstat.log" \
   u 1:VAL(i,3) t word(USERS,i)." cpu:".i  __STYLE0__, \
"" u 1:VAL(i,4) t word(USERS,i)." mem:".i  __STYLE0__

I do not fully understand syntax - which is mem and which is cpu?
Code:
USERS="user1 user2 user3"
g = (3*(g-1) + c
c= (3*(g-1) + c
...
what is i?
 
Old 07-28-2017, 08:06 PM   #5
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010
Is line 6 missing parens?
 
Old 07-29-2017, 01:52 AM   #6
prompt32
LQ Newbie
 
Registered: Oct 2013
Location: Greece
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by BW-userx View Post
I do not fully understand syntax - which is mem and which is cpu?
Code:
USERS="user1 user2 user3"
g = (3*(g-1) + c
c= (3*(g-1) + c
...
what is i?

Code:
VAL(user_index,column_index)=3*(user_index-1)+column_index
 
Old 07-29-2017, 03:35 AM   #7
prompt32
LQ Newbie
 
Registered: Oct 2013
Location: Greece
Posts: 7

Original Poster
Rep: Reputation: Disabled
https://stackoverflow.com/questions/...ting-with-loop
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to plot a bar graph on Gnuplot LXer Syndicated Linux News 0 05-03-2016 09:20 AM
[SOLVED] making a gnuplot 3d graph or gnuplot fence plot Rinndalir Programming 3 10-23-2015 01:10 PM
GNUplot - plot a subset of a data column MALDATA Linux - Software 2 03-11-2015 12:11 PM
[SOLVED] gnuplot: how to plot individual plots in separate windows vijay_babu1981 Linux - Software 4 11-17-2012 10:24 AM
in gnuplot; move title in plot command? shengchieh Linux - Software 0 12-29-2004 12:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration