# How to Plot Data?

**URL:** <https://www.ruby-forum.com/t/how-to-plot-data/188372>\
**Category:** Ruby\
**Created:** [May 11, 2010, 2:07am UTC](https://www.ruby-forum.com/t/how-to-plot-data/188372 "2010-05-11T02:07:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![iroupa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c0e974/32.png) [@iroupa](https://www.ruby-forum.com/u/iroupa)\
**Post date:** [May 11, 2010, 2:07am UTC](https://www.ruby-forum.com/t/how-to-plot-data/188372/1 "2010-05-11T02:07:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![iroupa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c0e974/32.png) [@iroupa](https://www.ruby-forum.com/u/iroupa)\
**Post date:** [May 11, 2010, 8:36am UTC](https://www.ruby-forum.com/t/how-to-plot-data/188372/2 "2010-05-11T08:36:18Z")

</div>

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/](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](http://ctioga2.rubyforge.org/doc/getting-started.html) to see if it can  
fit your needs.

Cheers,

---

<div class="post-metadata">

**Author:** ![iroupa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c0e974/32.png) [@iroupa](https://www.ruby-forum.com/u/iroupa)\
**Post date:** [May 11, 2010, 4:51pm UTC](https://www.ruby-forum.com/t/how-to-plot-data/188372/3 "2010-05-11T16:51:18Z")

</div>

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/](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](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.

---

<div class="post-metadata">

**Author:** ![iroupa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c0e974/32.png) [@iroupa](https://www.ruby-forum.com/u/iroupa)\
**Post date:** [May 11, 2010, 5:17pm UTC](https://www.ruby-forum.com/t/how-to-plot-data/188372/4 "2010-05-11T17:17:30Z")

</div>

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…

> **[Category: Graphing - The Ruby Toolbox](https://www.ruby-toolbox.com/categories/graphing.html)**
>
> Explore and compare open source Ruby libraries

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

---

<div class="post-metadata">

**Author:** ![iroupa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c0e974/32.png) [@iroupa](https://www.ruby-forum.com/u/iroupa)\
**Post date:** [May 11, 2010, 6:21pm UTC](https://www.ruby-forum.com/t/how-to-plot-data/188372/5 "2010-05-11T18:21:45Z")

</div>

On 5/10/10, Ivo R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![iroupa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c0e974/32.png) [@iroupa](https://www.ruby-forum.com/u/iroupa)\
**Post date:** [May 12, 2010, 1:08pm UTC](https://www.ruby-forum.com/t/how-to-plot-data/188372/6 "2010-05-12T13:08:35Z")

</div>

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/](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](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](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.

---

<div class="post-metadata">

**Author:** ![iroupa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c0e974/32.png) [@iroupa](https://www.ruby-forum.com/u/iroupa)\
**Post date:** [May 12, 2010, 5:07pm UTC](https://www.ruby-forum.com/t/how-to-plot-data/188372/7 "2010-05-12T17:07:47Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![iroupa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c0e974/32.png) [@iroupa](https://www.ruby-forum.com/u/iroupa)\
**Post date:** [May 12, 2010, 2:30pm UTC](https://www.ruby-forum.com/t/how-to-plot-data/188372/8 "2010-05-12T14:30:27Z")

</div>

Hello Ivo,

> I’ve install ctioga and take a look at  
> [http://sciyag.rubyforge.org/ctioga/tutorial/how\_to\_read\_this\_tutorial.html](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](http://www.kitp.ucsb.edu/~paxton/tioga.html)

Cheers,
