I am using PLplot with PlCairo and GTK, the whole program being coded in
Ocaml and thus using Ocaml bindings.
My question actually has two steps:
*How to modify dynamically the size of a figure ?
*How to update a figure with different values (remove the curve(s) with the
old values and then write new ones) ?
The example (
uses a scale mechanism which just scale the figure to the new size. This is
a problem in the case where the size of the figure changes, and then, the
figure appears either too small or too big inside the window.
I wanted to redraw the figure each time the size of the window changes (eg.:
on an expose event on a drawing area in GTK).
I first tried to create a new Cairo context and Plplot stream through
plinit_cairo and then draw my curves with the usual functions (plcol0,
plwid, plline) each time the window changes of size but it creates an empty
window from the beginning.
I also tried to clear the graph by using plclear and then, write again on it
with some plplot commands, but is not working.
Second interrogation, how can I erase and then write into a PLplot stream.
I tried to use to the timer from GTK to launch a function that will interact
with the PLplot stream (plclear and then functions to draw), but it's not
working, the graph stays the same.
I don't know the internal mechanisms used by plplot, so maybe, in both
cases, it is impossible to do what I just explained.
Thanks in advance for your time.
From: Hezekiah M. Carty <hezekiahcarty@us...> - 2010-09-18 17:01:55
On Sat, Sep 18, 2010 at 9:46 AM, Johan Mazel <johan.mazel@...> wrote:
> I finally found how do to do everything that I was looking for on this
> I'll just simply join the example to this mail, for if it interests anybody,
> they would have access. This example is heavily based on the xgtk_interface
> example. I simply remove the plot of map and my own picked from the example
> x01 from the examples on the PLplot website.
> In order to demonstrate the possible reactualization of the plot, I simply
> used a GTK timer that rewrite the curve and add some random noise each 2
> If you see any problem, or wrong use of PLplot in my code, please, signal
> them to me.
You use of Plcairo looks good to me. Thank you for the example - I'm
glad to see that the code is working for you! Plcairo is still very
raw and the API is not set in stone yet, so if you have any
suggestions for improvements or patches to implement improvements they
are more than welcome!