TriPlot is a simple plotter written in the Ruby programming language.

 

It has three modes of usage:

 

- standalone mode - where you can select how to fetch data to plot (file, serial port, socket, pipe, stdin.. etc) [this mode is not yet implemented - for now if you run  the file you will get a simple demo of the plotter instead]

 

- component mode - subclass of Wx::Panel and can be incorporated into other controls or frames. [this works fine but is not documented]

 

- module mode - where it acts as a simple extension to your program. You simply "require plotpanel.rb", then instantiate TriPlotter - class, and you can send your numeric data to it, instead of printing it to stdout.

 

 

What is needed?

 

- Ruby 1.8.6

- WxRuby 1.9.5

 

 

Example of usage in module mode:

(the code below is complete program that will plot a straight line)

 

require "plotpanel.rb"

myPlotter = TriPlotter.new            # create one plotter with default settings

100.times { |i| myPlotter << i }      # send some data to the plotter

TriPlotter.wait                       # wait for user to close the plotter window, if you want

                                      # more plotters than 1 you MUST create them

                                      # before calling TriPlotter.wait

 

 

Example of usage in standalone mode:

 

Just run the file: plotpanel.rb, and you will get simple demo of the plotter, animated plot of slightly randomized sinus function, until closed.

 

 

The instance returned by TriPlotter.new has following methods that you can access to customize the plotter:

 

.transform.x_adjust=                   # provide one of:   :fixed , :fit_all :follow_newest, default is :follow_newest

.transform.y_adjust=                    # provide one of:  :fixed,  :fit_all,  :fit_screen, default is :fit_screen

.transform.x_size=                        # meaning depends on adjust-settings

.transform.x_origin=                    # meaning depends on adjust-settings

.transform.y_size=                        # meaning depends on adjust-settings

.transform.y_origin=                    # meaning depends on adjust-settings

.transform.marigin=                      # hash with keys: :titlebar,:xbar,:ybar,:extrabar - spec. sizes of the bars - values of the hash are the sizes in pixels

.transform.gridlines=                  # how many gridlines along x-axis, 0 to turn off grid, grid is always pixel-quadratic so y-amount depends on the size of the window

.title=                                              # default "Unnamed plot"

.buffer_size=                                  # how many values to keep before throwing away the oldest, default is 50000

.col                                                    # returns a hash with keys: :background, :titlebar, :extrabar, :xbar, :ybar, :plot, :reference, :grid ; col[:xbar] = Colour.new(0,0,0) will set x-bar color to black.

 

only two of those settings may be of immediate importance to user:

 

.transform.x_adjust=                             # sometimes you may want to change this to :fit_all, if you want to see all of your points at once.

                                                            # do not use :fit_all if you have 1000+ point and want smooth animation

.transform.x_size=                                # how many points to show on screen when x_adjust is set to follow newest

 

 

 

The instance returned by TriPlotter.new has following methods that you can call to insert the data

 

.add_data( y_value, x_value, channel )        # x_value can be omitted - then it will be +1 for every call, channel will be 0 if omitted, ATT! only 0 is supported atm or crash

<< y_value                                                                # same as add_data( y_value )

 

 


Download version 0.2: here




Visitors since December 2008: