Gnu Plot
Nothing to do with RMS and FSF and released under a rather strange, or perhaps I should say unusual, licence that requires distrution of modified versions as patches rather than complete packages. Never mind, it doesn't seem to restrict use or modification.
The GnuPlot implementers have done a marvellous job but of course they can't do everything all at once so until Ricardo Sasson Saat (rssat@altavista.net) created CVBGnuPlot there was no convenient way for VB programs to use it. CVBGnuPlot is a straightforward wrapper around GnuPlot that lets a VB program pretend that it is talking to a COM object. This at least lets you get started but it has the drawback from a VB programmers point of view that the interface is very much narrative instead of declarative. To make it easier to plot data sets derived from collections of objects I needed to write code to convert my data into the narrative form. I could have written ad-hoc code where it was needed and made it drive CVBGnuPlot directly but I felt that that would result in lots of code duplication and also be difficult to maintain as there would not be an easily discerned boundary between the collections of data objects and the plot. It seemed better to create some classes instances of which could act as a staging area for the data. If you do decide to look at the code please remember that this is not an attempt to expose all the power of GnuPlot, CVBGnuPlot already does that perfectly well, the purpose is quite the opposite: I want to hide as much complexity as possible and create an interface that does what I want and not much more. Nonetheless it might be useful to someone else because while it is restricted to a small subset of GnuPlot's capabilities it is not directed toward any specific application.
Requirements
- Simplify the creation of 2d plots
- I am only interested, at the moment, in 2d plots with one x axis and two y axes. I need an indefinite number of series for each axis pair
- Allow client to create data series
- only simple XY plots are of interest to me just now so a series is a list of coordinate pairs plus some series specific settings like style.
- Allow each series to be assigned to any axis pair
- An axis pair is my word for the set of information connected by the use of the x1y1, x1y2, x2y1, x2y2 names. A series can be associated with only one of these.
- Provide properties that control program wide behaviour
- There is a huge number of these, many of which are irrelevant to my purposes so an interface that limits attention to just those that are relevant is a help.
- Provide constant and enumerations to hide string
- GnuPlot is an interpreter and as such reads text streams. In an object oriented environment it is much simpler if we can use symbols instead of strings. The classes take care of conversion and creation of the strings and the VB IDE can display the valid values for properties when they are declared as instances of enumerated types.
Implementation
The current implementation is very much an exploration. It consists of three classes in addition to Ricardo Sasson Saat's (rssat@altavista.net) CVBGnuPlot and vbgnuplotmodule. These classes are:
- cAxisPair
- each instance of this represents a pair of axes (x1 or x2 and y1 or y2). The properties could hold all the values that can be unambiguously associated with an axis pair.
- cAxis
- instances of this represent one axis and all the properties that apply to it such as title, tics, format.
- cChart
- This is the master class. Instances of this are instantiated by the client. They contain axes and axispairs. The properties of cChart are those things that apply regardless of axis or axispair.
- cSeries
- A series is a list of coordinate pairs and all the properties that apply to that list such as style, title.
No comments:
Post a Comment