Several horizontal lines

View: New views
5 Messages — Rating Filter:   Alert me  

Several horizontal lines

by Daniel Clemente-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Hi, I look for orientation on how to plot a graph I have seen no examples for.

  Imagine you have this data consisting of tower_name+tower_height:

Burj Dubai, 818
KVLY-TV mast, 628.8
CN Tower, 553.3
Sears Tower, 527.3
Taipei 101, 509.2

  I want a graph with 5 horizontal lines, each at the height specified by the second parameter.
  Similar in nature to this graph: https://eshu.ubuntu-eu.org/cgi-bin/munin-cgi-graph/ubuntu-eu.org/eshu/smart_sdb-month.png

  I could do manually: plot 818 title "Burj Dubai", 628.8 title "KVLY-TV mast", 553.3 title "CN tower", 527.3 title "Sears Tower", 509.2 title "Taipei 101"
  But I want the data to be read from a file.

  Can this be done with a gnuplot command?

  Thanks,
Daniel



     

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Gnuplot-info mailing list
Gnuplot-info@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-info

Re: Several horizontal lines

by Thomas Sefzick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

you need gnuplot 4.3-cvs

set datafile separator ","
t=""
plot for [i=0:4] 'ts.dat' us ((i==0&&$0==0)?(b=$2,t=stringcolumn(1)):99 , $0==0?(a=b):99, $0==(i+1)?(b=$2,t=stringcolumn(1)):99 , $0):(a) with lines title t

Daniel Clemente-2 wrote:

Hi, I look for orientation on how to plot a graph I have seen no examples for.

  Imagine you have this data consisting of tower_name+tower_height:

Burj Dubai, 818
KVLY-TV mast, 628.8
CN Tower, 553.3
Sears Tower, 527.3
Taipei 101, 509.2

  I want a graph with 5 horizontal lines, each at the height specified by the second parameter.
  Similar in nature to this graph: https://eshu.ubuntu-eu.org/cgi-bin/munin-cgi-graph/ubuntu-eu.org/eshu/smart_sdb-month.png

  I could do manually: plot 818 title "Burj Dubai", 628.8 title "KVLY-TV mast", 553.3 title "CN tower", 527.3 title "Sears Tower", 509.2 title "Taipei 101"
  But I want the data to be read from a file.

  Can this be done with a gnuplot command?

  Thanks,
Daniel



     

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Gnuplot-info mailing list
Gnuplot-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnuplot-info

Parent Message unknown Re: Several horizontal lines

by Daniel Clemente-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




Thanks, this exactly parses the file. It will also be a good exercise to understand that.

  I supposed there would be a simpler way to do this in gnuplot. It is a common graph.


> you need gnuplot 4.3-cvs
>
> set datafile separator ","
> t=""
> plot for [i=0:4] 'ts.dat' us
> ((i==0&&$0==0)?(b=$2,t=stringcolumn(1)):99 ,
> $0==0?(a=b):99, $0==(i+1)?(b=$2,t=stringcolumn(1)):99 ,
> $0):(a) with lines
> title t
>
>



     

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Gnuplot-info mailing list
Gnuplot-info@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-info

Re: Several horizontal lines

by Thomas Sefzick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

simpler ways - 'outside' gnuplot, maybe, but 'inside', i don't think so,
because you read y-values in, which are then to be used as constant
functions after reading them in, that's somehow a 'misuse' of gnuplots
plotting mechanism.

'outside' gnuplot, e.g.:

load "< awk --field-separator \",\" 'BEGIN {temp = sprintf(\"plot\")} {if (NR>1) temp = temp \",\" ; temp = temp $2 \" title \" \"\\\"\" $1 \"\\\"\"} END{print temp}' ts.dat"

Daniel Clemente-2 wrote:
Thanks, this exactly parses the file. It will also be a good exercise to understand that.

  I supposed there would be a simpler way to do this in gnuplot. It is a common graph.

> you need gnuplot 4.3-cvs
>
> set datafile separator ","
> t=""
> plot for [i=0:4] 'ts.dat' us
> ((i==0&&$0==0)?(b=$2,t=stringcolumn(1)):99 ,
> $0==0?(a=b):99, $0==(i+1)?(b=$2,t=stringcolumn(1)):99 ,
> $0):(a) with lines
> title t
>
>



     

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Gnuplot-info mailing list
Gnuplot-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnuplot-info

Parent Message unknown Re: Several horizontal lines

by Daniel Clemente-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



> simpler ways - 'outside' gnuplot, maybe, but 'inside', i
> don't think so,

  Ok, and the important question: should there be a simpler way inside Gnuplot?

  I think the graph can be easily described. With this data:

Burj Dubai, 818
KVLY-TV mast, 628.8
CN Tower, 553.3
Sears Tower, 527.3
Taipei 101, 509.2

  You could say:
  For each data line, plot y=$2 with title $1, without clearing the screen between plots.


  I have seen a similarity with the reread command (http://www.gnuplot.info/docs/node151.html).

  In fact, the graph I want could be made a specific case of a more general multi-plot graphing system. Imagine this data:

Quadratic, x**2
Five, 5
Sinus, sin(x)

  gnuplot could parse this and plot $2 with title $1, all in the same place (so you would see the solution to x**2=5).

  Could this be useful in general? Is it a good idea to extend gnuplot to handle this?


-- Daniel



     

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Gnuplot-info mailing list
Gnuplot-info@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-info