Which plotting library

676 views
Skip to first unread message

DavidA

unread,
Sep 7, 2009, 10:11:36 AM9/7/09
to wx-users
Hi

We are developing with wxWidgets/C++ on Windows and Linux and need to
add x/y plots to our GUI.

I am aware that there are a number of plotting components/libraries
available, e.g. wxPlotCtrl, wxChart, wxMathPlot, PlPlot.

Would anyone like to compare the status/functionality of these and
recommend one for me to try first please?

Any tips would be appreciated.

BR

David

DavidA

unread,
Sep 7, 2009, 10:19:17 AM9/7/09
to wx-users
Hi

Sorry, I accidentally hit send before I completed my message.

I posted this question asking for a recommendation some weeks ago on
the wxWidgets forum but got no response.

I have looked at the wxPlotCtrl code that is shipped with wxWidgets
2.8.10 but that seems to be for a very old version of PlPlot. Am I
correct?

Best regards

David

DavidA

unread,
Sep 7, 2009, 10:36:42 AM9/7/09
to wx-users
One more point: I would like to plot bar charts as well as x/y graphs.

David

Vadim Zeitlin

unread,
Sep 7, 2009, 6:04:50 PM9/7/09
to wx-u...@googlegroups.com
On Mon, 7 Sep 2009 07:11:36 -0700 (PDT) DavidA <dand...@talktalk.net> wrote:

D> We are developing with wxWidgets/C++ on Windows and Linux and need to
D> add x/y plots to our GUI.
D>
D> I am aware that there are a number of plotting components/libraries
D> available, e.g. wxPlotCtrl, wxChart, wxMathPlot, PlPlot.
D>
D> Would anyone like to compare the status/functionality of these and
D> recommend one for me to try first please?

All I can say is that I had to do something related to what you did (as
you, I needed both x/y graphs and a special kind of bar charts, namely OHLC
(http://en.wikipedia.org/wiki/OHLC) charts) and I chose PlPlot with its wx
bindings to do it. It did work but if I had to choose again I'd probably
use something else because PlPlot turned out to be very/too low-level and I
wasn't even sure if I really saved time by using it in the first place
instead of just doing everything myself. PlPlot is definitely flexible
enough to do everything you need but I'd prefer something more useful out
of the box. E.g. unlike wxMathPlot it doesn't have any support for panning/
zooming/scrolling and I had to implement the subset of these that I needed
myself on top of it.

Unfortunately I didn't really try wxMathPlot so I can't say much about it
but from its description and what I know about PlPlot now I think I'd
rather choose it. BTW, there is another plotting library missing from your
list: wxFreeChart (http://wxcode.sourceforge.net/components/freechart/). It
is very new and didn't even exist when I started my project, otherwise I'd
have almost certainly used it because it was the only one which supported
OHLC plots. But again, I didn't [try to] use it so I can't say much about
it neither.

If you're going to do some testing of all these libraries it would be nice
if you could summarize your results in a post here or on a Wiki page (or
both, by posting here a link to the wiki) as I'm sure this would be useful
for others as well.

Thanks and good luck,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Werner Smekal

unread,
Sep 8, 2009, 8:29:34 AM9/8/09
to wx-u...@googlegroups.com
Hi,

Vadim already replied to your Email, especially about PLplot. Since
I'm the main developer of the wxWidgets driver and bindings I'm kind
of biased obviously, but I just wanted to add some more details, which
where important to me, so that I chose PLplot for my project (and
wrote the wxWidgets driver). As Vadim explained, PLplot is rather low
level (but also very fast) and other things like panning/zooming need
still to be added to the driver (I already wrote the code, but it's
too specific to my project code, so I need to rewrite that). On the
other hand if you only need x/y plots, this is easily done with PLplot
and you have many other drivers available (e.g. svg, png, jpeg, pdf,
ps, gif, ....) which allow you to export the plot to several file
formats (which was important for me).

PLplot can be configured and compiled on Mac OS X, Linux and Windows
(and it's also supported there). The mailing list is in general very
helpful and PLplot is actively developed by a number of developers
(about 10), so chances are low, that PLplot will be dead in the near
future. The developers also gladly except patches and additions to the
code. The documentation is not perfect, but at least there is some and
there is also a wiki with a lot of helpful information. Further,
PLplot's strong area is scientific plots.

If you need only one small x/y plot somewhere in your app, PLplot is
maybe an overkill, especially for scientific applications this is the
library to use IMO.

Regards,
Werner
--
Dr. Werner Smekal
Institut fuer Allgemeine Physik
Technische Universitaet Wien
Wiedner Hauptstr 8-10
A-1040 Wien
Austria
DVR-Nr: 0005886

email: sme...@iap.tuwien.ac.at
web: http://www.iap.tuwien.ac.at/~smekal
phone: +43-(0)1-58801-13463 (office)
+43-(0)1-58801-13469 (laboratory)
fax: +43-(0)1-58801-13499

DavidA

unread,
Sep 8, 2009, 10:05:01 AM9/8/09
to wx-users
Hi Vadim and Werner

Thank you both for your replies. wxFreeChart looks very interesting
but perhaps I should take a closer look at PlPlot first, given the
strength of its developer base.

Werner, I am somewhat confused about the wxWidgets driver for PlPlot.
Is your driver the same as the code in:

C:\wxWidgets-2.8.10\contrib\build\plot ?

If not, where should I find your driver?

How does your work relate to that of German Carrera here:

http://personales.unican.es/carreracg/web/wxplot.html ?

Does your driver support the latest version of PlPlot?

Finally, please will you give me a very brief overview of how to get
started? I.e. what files and libraries do I need?

Thanks

David

Werner Smekal

unread,
Sep 8, 2009, 2:08:24 PM9/8/09
to wx-u...@googlegroups.com
Hi David,
>
> Werner, I am somewhat confused about the wxWidgets driver for PlPlot.
> Is your driver the same as the code in:
>
> C:\wxWidgets-2.8.10\contrib\build\plot ?

No, this class was written by Robert Roebling (I think), and has
nothing to do with PLplot.
>
> If not, where should I find your driver?

It's already in the PLplot source code (http://plplot.sf.net). We just
released version 5.9.5. The driver is in the drivers directory, but
PLplot also provides "bindings", that is a wxPLplotstream, where you
can access the PLplot API, as well as an easy Widgets wxPLplotWindow.
See the sample in examples/c++/wxPLplotDemo.cpp .

You need cmake to configure PLplot, it will also find the installed
wxWidgets package (usually ;).

>
> How does your work relate to that of German Carrera here:
>
> http://personales.unican.es/carreracg/web/wxplot.html ?

He was first :). Frank Hubert or so wrote a wxWidgets driver 1999 or
so, German Carrera 2005 or so, German donated his code to the PLplot
community. At this time I already have written a driver based on Frank
Huberts code, but in the meantime it's completely rewritten. German
uses only wxDC drawing functions, while we use already
wxGraphicsContext as well as the AGG library alternatively for much
nicer output and font support (but still have a wxDC backend for fast
output).
>
> Does your driver support the latest version of PlPlot?

"My" driver *is* in the latest version of PLplot.
>
> Finally, please will you give me a very brief overview of how to get
> started? I.e. what files and libraries do I need?

Download PLplot and install cmake. It's maybe better to start on Linux
first, since Windows is sometimes a PIA. Untar PLplot source and
create a build directory. cd into build directory and run "cmake -
DBUILD_TEST=ON path-to-PLplot-source". cmake needs wx-config on Linux
to find wxWidgets obviously. Then "make". The BUILD_TEST=ON option
will also build the examples automatically. It should configure and
compile without problems (at least on Linux with wxWidgets 2.8.x). run
"examples/c/x01c" and choose the wxwidgets driver. Run "examples/c++/
wxPLplotDemo" to see the library in action embedded in a wxWidgets
application.

This should be it (wrote that off top of my head).

HTH,
Werner

>
> Thanks

Vadim Zeitlin

unread,
Sep 8, 2009, 3:38:45 PM9/8/09
to wx-u...@googlegroups.com
On Tue, 8 Sep 2009 14:29:34 +0200 Werner Smekal <sme...@iap.tuwien.ac.at> wrote:

WS> PLplot can be configured and compiled on Mac OS X, Linux and Windows
WS> (and it's also supported there). The mailing list is in general very
WS> helpful and PLplot is actively developed by a number of developers

Yes, indeed, I got a lot of help and useful advice on the PLplot list and
from Werner himself and I'm grateful for this. This is important and I
should have mentioned this in my original message.

WS> Further, PLplot's strong area is scientific plots.

I guess it would have worked better if I wanted to do something closer to
this. Unfortunately what I needed was really quite different which is why
it left me with a feeling that it might not have been the best choice.

Regards,

DavidA

unread,
Sep 9, 2009, 6:04:48 AM9/9/09
to wx-users
Hi Werner

Thanks very much for answering all my questions. I may ask further
questions on the PLplot mail list.

David

Kenneth Porter

unread,
Sep 9, 2009, 8:28:43 AM9/9/09
to wx-u...@googlegroups.com
--On Monday, September 07, 2009 8:11 AM -0700 DavidA
<dand...@talktalk.net> wrote:

> We are developing with wxWidgets/C++ on Windows and Linux and need to
> add x/y plots to our GUI.

I haven't tried to use it (yet), but Visualization Toolkit (VTK) looks
interesting:

<http://www.vtk.org/>

It's available wrapped in an application as ParaView:

<http://www.paraview.org/>

I'm considering using it for displaying exaggerated contour maps in a
surface analysis application.


Colin Barnette

unread,
Sep 10, 2009, 11:54:56 AM9/10/09
to wx-u...@googlegroups.com
David,

Recently I have started working with PyPlot (wx.lib.plot) and, though it
might take a minute to familiarize yourself with the code, it is working
great for me so far. Perhaps you might find it helpful.

Good Luck,
--
Colin Barnette
<colin dot barnette at gmail dot com>

DavidA

unread,
Sep 14, 2009, 8:34:47 AM9/14/09
to wx-users
Hi Colin

>Recently I have started working with PyPlot ...

Thanks. Does PyPlot only support Python, or can one use C++ with it?

Best regards

David

Jack Dodds

unread,
Sep 18, 2009, 5:04:45 PM9/18/09
to wx-u...@googlegroups.com

I have been using a system set up according to the Eclipse CDT/MinGW/MSYS
setup guide:

http://wiki.wxwidgets.org/Eclipse,_CDT_&_MingW_&_MSYS_Setup_Guide#Building_a
nd_Configuring_wxWidgets

The guide contains the warning:
Caution: If you plan to use other libraries which depend on wxWidgets (e.g.
PLplot), be aware that although this method which uses ./configure to create
the makefiles will result in Windows libraries, it will not place them in
the same paths as if you were to use mingw32-make directly with the
pre-existing makefiles. The location of build.cfg may also be a significant
factor. CMake, for example, can search for wxWidgets via two independent
methods labeled 'unix' and 'win32'. This ./configure method is not
compatible with the 'win32' search method.

Now I want to use PLplot and sure enough, the standard CMake build of PLplot
doesn't work!

Can anyone advise me how to get PLplot integrated with the aforementioned
set of tools?

Thanks

Jack Dodds
Geo Equipment Manufacturing Ltd.
Geotech Ltd.
245 Industrial Parkway North
Aurora, Ontario, Canada
L4G 4C4
Phone: 905-841-5004
Fax: 905-841-0611
Email: ja...@geotech.ca


Jack Dodds

unread,
Nov 24, 2009, 3:49:52 PM11/24/09
to wx-u...@googlegroups.com

I'm trying to display numbers, left aligned, in a wxGrid using
wxGridCellNumberRenderer() and wxGridCellFloatRenderer().

The contents of the cells are always right aligned, even though I set left
alignment with wxGrid::SetCellAlignment() and/or wxGrid::SetColAttr().

In other cells where I specify wxGridCellStringRenderer(), I have
successfully set both left and right alignment with
wxGrid::SetCellAlignment() and wxGrid::SetColAttr().

Is this the way the Number and Float renderers work - or am I doing
something wrong?

Jack Dodds

Vadim Zeitlin

unread,
Nov 24, 2009, 9:14:45 PM11/24/09
to wx-u...@googlegroups.com
On Tue, 24 Nov 2009 15:49:52 -0500 Jack Dodds <ja...@geotech.ca> wrote:

JD> I'm trying to display numbers, left aligned, in a wxGrid using
JD> wxGridCellNumberRenderer() and wxGridCellFloatRenderer().
JD>
JD> The contents of the cells are always right aligned, even though I set left
JD> alignment with wxGrid::SetCellAlignment() and/or wxGrid::SetColAttr().

Looking at the code of wxGridCellFloatRenderer::Draw() this isn't really
surprising as it does the following:

// draw the text right aligned by default
int hAlign, vAlign;
attr.GetAlignment(&hAlign, &vAlign);
hAlign = wxALIGN_RIGHT;

wxRect rect = rectCell;
rect.Inflate(-1);

grid.DrawTextRectangle(dc, GetString(grid, row, col), rect, hAlign, vAlign);

Obviously overwriting hAlign with wxALIGN_RIGHT is not a great idea, I
don't know why was this done even though apparently I did it myself in an
almost 10 year old r6210.

It looks like just initializing hAlign to wxALIGN_RIGHT before calling the
function should work as intended, i.e. use right alignment by default but
allow overriding it if another alignment is explicitly set. Could you
please test if this is really the case?

Thanks,

Jack Dodds

unread,
Nov 25, 2009, 8:47:05 AM11/25/09
to wx-u...@googlegroups.com
Hello Vadim,

Thanks for steering me to that code.

Could it be that the alignment is forced to wxALIGN_RIGHT because other
problems crop up when other alignments are used?

I'll try a mod to the code. To test it I'll have to remember how to build
wxWidgets, which I haven't done for a few months!

Jack

Vadim Zeitlin

unread,
Nov 25, 2009, 9:23:10 AM11/25/09
to wx-u...@googlegroups.com
On Wed, 25 Nov 2009 08:47:05 -0500 Jack Dodds <ja...@geotech.ca> wrote:

JD> Could it be that the alignment is forced to wxALIGN_RIGHT because other
JD> problems crop up when other alignments are used?

I really don't know/remember but it seems just like a bug to me.

JD> I'll try a mod to the code. To test it I'll have to remember how to build
JD> wxWidgets, which I haven't done for a few months!

It hasn't changed since then :-)

Good luck,

Jack Dodds

unread,
Nov 26, 2009, 2:12:43 PM11/26/09
to wx-u...@googlegroups.com

I've tested this fix. It works. Thanks for your help, Vadim.

The fix was to
file grid.cpp, functions
wxGridCellNumberRenderer::Draw() and wxGridCellFloatRenderer::Draw()

and consisted of moving the hAlign = statement up one line to precede the
GetAlignment call, in each function, giving

hAlign = wxALIGN_RIGHT;
attr.GetAlignment(&hAlign, &vAlign);

Looking at the code of GetAlignment(), it seems that presetting hAlign to
wxALIGN_RIGHT before the call to GetAlignment() only has an effect if there
is no alignment set for the cell, and no default alignment set (and the
latter seems to be an error condition). I'm not sure if this case is
important.

Looks like the original intent was to make wxALIGN_RIGHT the default
alignment for numeric fields (since wxALIGN_LEFT is the overall default).

Jack Dodds


> -----Original Message-----
> From: wx-u...@googlegroups.com [mailto:wx-u...@googlegroups.com] On
> Behalf Of Vadim Zeitlin
> Sent: November 24, 2009 21:15
> To: wx-u...@googlegroups.com
> Subject: Re: Left alignment and renderers
>

Vadim Zeitlin

unread,
Nov 26, 2009, 8:48:17 PM11/26/09
to wx-u...@googlegroups.com
On Thu, 26 Nov 2009 14:12:43 -0500 Jack Dodds <ja...@geotech.ca> wrote:

JD> Looking at the code of GetAlignment(), it seems that presetting hAlign to
JD> wxALIGN_RIGHT before the call to GetAlignment() only has an effect if there
JD> is no alignment set for the cell, and no default alignment set (and the
JD> latter seems to be an error condition). I'm not sure if this case is
JD> important.
JD>
JD> Looks like the original intent was to make wxALIGN_RIGHT the default
JD> alignment for numeric fields (since wxALIGN_LEFT is the overall default).

Yes, it definitely was. So if the fix results in these fields not being
right aligned by default any more then it actually doesn't work... And
looking at the code more carefully it does seem like it's impossible to
have a NULL m_defGridAttr in wxGridCellAttr and so some alignment will
always be returned. Which is definitely not what we want...

The simplest solution I can see right now is to replace all

int hAlign, vAlign;
attr.GetAlignment(&hAlign, &vAlign);

hAlign = wxRIGHT;

blocks with something like this:

int hAlign, vAlign;
if ( attr.HasAlignment() )
attr.GetAlignment(&hAlign, &vAlign);
else // no non-default alignment
{
hAlign = wxRIGHT;
vAlign = wxTOP;
}

but this is still far from ideal...

I think I solved the problem in the svn trunk with r62728 (you will also
need r62727 it depends on) and in principle this could be backported to
2.8, although more work would be needed.

Regards,

Jack Dodds

unread,
Nov 27, 2009, 8:50:21 AM11/27/09
to wx-u...@googlegroups.com
Hello Vadim,

The present fix solved my problem, and the more complicated one that you
propose would also do that. If the problem is fixed in a better way in 2.9
then it seems most sensible to work with this patch for now, and upgrade to
2.9 or 3.0 in due course. Time and effort can be spent more productively on
other features!

Thanks again.

Jack
Reply all
Reply to author
Forward
0 new messages