I’ve started with gnuplot today and i tried some of the examples especially this one. What this does is it creates a Sin-Wave-Diagramm and puts it into a file and that’s what i want, but when i execute this code (it doesn’t matter if i put this into a model or directly into the Rails Console) it does absolutely nothing.
So i tried to log the activities and the code runs well. Ive inspected the plot-Object with a logger and that’s the output (sorry about the formating, but i get some strange outputs with Blockquotes):
#<Gnuplot::Plot:0x2d597c0 @cmd="plot", @settings=[[:set, "terminal", "png"], [:set, "output", "\"/root/rails/drapetest/tst.png\""], [:set, "xrange", "[-10:10]"], [:set, "title", "\"Array Plot Example\""], [:set, "xlabel", "\"x\""], [:set, "ylabel", "\"sin(x)\""]], @arbitrary_lines=[], @data=[#<Gnuplot::DataSet:0x2d58ba8 @data="sin(x)", @axes=nil, @smooth=nil, @matrix=nil, @linecolor=nil, @linewidth=4, @using=nil, @with="lines", @title=nil>]>
As far as i know is that this is okay (Im just curious why he puts the path in two “” ).
what i’ve done next is, that i put the code directly into the index-Action of a Controller and he renders the output into a window and that’s exactly what he should do according to the plugin-documentation.
So the Data is okay and the overall output is okay, but he just doesn’t put it into a file.
I’ve seen the example above in like every tutorial according to gnuplot and it seems to work.
Some Data:
The System is a RaspberryPi (yes Ruby on Rails runs pretty good on a Raspberry) with the latest Raspian OS. The CPU is NOT overclocked.
Ruby-Version: 1.9.3p374
Rails Version: 3.2.11
I also tested the same code on my Laptop:
i7 QM 2.2GHz Quad Core
8 GB RAM
Linux Mint 13 x64
Same Ruby and Rails-Versions
I got the same problems there too.
Okay i figured this out and i’m embarassed to admit it, but i simply forgott to add a
require 'gnuplot'to my class.That was a REALLY dumb one and i could bite myself, but still: thanks!