How to Plot Data?

Hi all,

I would like to plot some data from .txt or .csv files. Is it possible?
And what gem do you use? I found rgnuplot but I can’t use it…

Thanks in advanced for your help.

Ivo R.

Hello,

I would like to plot some data from .txt or .csv files. Is it possible?
And what gem do you use? I found rgnuplot but I can’t use it…

Try using ctioga:

sudo gem install ctioga

and then

ctioga file.txt # → plot column 2 versus column 1
ctioga file.txt@1:4 # → plot column 4 versus column 1
ctioga file.txt @1:4 # → plot column 2 and column 4 against column 1

Try ctioga --help to see all you can do or look at the doc:
http://sciyag.rubyforge.org/ctioga/doc/

NB: I don’t think ctioga handles csv yet but a simple regexp could
change all your commas in spaces and you get a valid file. Or even
something like this should be enough.

cat file.csv | tr ‘,’ ’ ’ > file.txt

NB2: ctioga is currently being reimplemented in ctioga2 which will
have some nice features as being able to be launched from a file
rather than from the command-line, but all the currently available
features of ctioga have not yet been implemented in ctioga2. Look at
http://ctioga2.rubyforge.org/doc/getting-started.html to see if it can
fit your needs.

Cheers,

Jean-Julien F. wrote:

Hello,

I would like to plot some data from .txt or .csv files. Is it possible?
And what gem do you use? I found rgnuplot but I can’t use it…

Try using ctioga:

sudo gem install ctioga

and then

ctioga file.txt # → plot column 2 versus column 1
ctioga file.txt@1:4 # → plot column 4 versus column 1
ctioga file.txt @1:4 # → plot column 2 and column 4 against column 1

Try ctioga --help to see all you can do or look at the doc:
http://sciyag.rubyforge.org/ctioga/doc/

NB: I don’t think ctioga handles csv yet but a simple regexp could
change all your commas in spaces and you get a valid file. Or even
something like this should be enough.

cat file.csv | tr ‘,’ ’ ’ > file.txt

NB2: ctioga is currently being reimplemented in ctioga2 which will
have some nice features as being able to be launched from a file
rather than from the command-line, but all the currently available
features of ctioga have not yet been implemented in ctioga2. Look at
http://ctioga2.rubyforge.org/doc/getting-started.html to see if it can
fit your needs.

Cheers,

Jean-Julien F.

Thank you for your help.

Cheers

Ivo R.

Ivo R. wrote:

Hi all,

I would like to plot some data from .txt or .csv files. Is it possible?
And what gem do you use? I found rgnuplot but I can’t use it…

Might be of use. Also the gnuplot gem should work.
GL.
-rp

On 5/10/10, Ivo R. [email protected] wrote:

Hi all,

I would like to plot some data from .txt or .csv files. Is it possible?
And what gem do you use? I found rgnuplot but I can’t use it…

The quickest and easiest way to make a one-off plot of some csv data
is to load it into a spreadsheet and create a plot from there. If you
want to create plots programmatically, follow the suggestions of
others in this thread.

Ivo R. wrote:

Jean-Julien F. wrote:

Hello,

I would like to plot some data from .txt or .csv files. Is it possible?
And what gem do you use? I found rgnuplot but I can’t use it…

Try using ctioga:

sudo gem install ctioga

and then

ctioga file.txt # → plot column 2 versus column 1
ctioga file.txt@1:4 # → plot column 4 versus column 1
ctioga file.txt @1:4 # → plot column 2 and column 4 against column 1

Try ctioga --help to see all you can do or look at the doc:
http://sciyag.rubyforge.org/ctioga/doc/

NB: I don’t think ctioga handles csv yet but a simple regexp could
change all your commas in spaces and you get a valid file. Or even
something like this should be enough.

cat file.csv | tr ‘,’ ’ ’ > file.txt

NB2: ctioga is currently being reimplemented in ctioga2 which will
have some nice features as being able to be launched from a file
rather than from the command-line, but all the currently available
features of ctioga have not yet been implemented in ctioga2. Look at
http://ctioga2.rubyforge.org/doc/getting-started.html to see if it can
fit your needs.

Cheers,

Jean-Julien F.

Thank you for your help.

Cheers

Ivo R.

Jean-Julien F.

I’ve install ctioga and take a look at
http://sciyag.rubyforge.org/ctioga/tutorial/how_to_read_this_tutorial.html
but I forgot to said that my OS is Windows and I’m using NetBeans 6.8 as
my IDE. Can I still use ctioga? And there is any tutorial for Windows
users?

Cheers

Ivo R.

There is no Windows tutorial, but if it works for you, let me know.
Note that you will also need LaTeX to be installed and reachable on
your computer as ctioga delegated the layout work to him (which allows
for the improved aesthetics compared to what gnuplot can do).

If you want to run in windows native, I’ve had success with installing
miktex. That’s with the gnuplot gem.

Barring that cygwin’s latex (under tetex package) might work.
GL.
-rp

Hello Ivo,

I’ve install ctioga and take a look at
http://sciyag.rubyforge.org/ctioga/tutorial/how_to_read_this_tutorial.html
but I forgot to said that my OS is Windows

Well, I have no idea if it will work on windows out of the box. I know
that it does within cygwin but other than that, it has not at all been
targeted for windows.

and I’m using NetBeans 6.8 as
my IDE.

IDE will not matter as ctioga is intended to be run from the
command-line (or called within a script using the system() method)

Can I still use ctioga? And there is any tutorial for Windows
users?

There is no Windows tutorial, but if it works for you, let me know.
Note that you will also need LaTeX to be installed and reachable on
your computer as ctioga delegated the layout work to him (which allows
for the improved aesthetics compared to what gnuplot can do).

If you want to control everything from within a Ruby script, you can
also look at the Tioga plotting library (which ctioga uses to quickly
make standard plots), see http://www.kitp.ucsb.edu/~paxton/tioga.html

Cheers,