plotting while preserving some properties

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

plotting while preserving some properties

Giovanni Di Stasi
Hi,

I am using Octave and Gnuplot in order to draw a "moving" graph; I'm doing
that by calling repeatedly plot(X) and replot() with the new matrix; Between
a plot and the next, I'd like the title, the ylabel and the xlabel to be
preserved (without having to call title(...), xlabel(...) and ylabel(...)
every time). How can I do that?

Another question: I call my script from bash (I made it executable and put
#! /usr/bin/octave -qf at the beginning) and, as I said above, I have to call
both plot and replot (If I just call plot, the figure won't even show up),
whilst, in the Octave command line, plot is sufficient. Shouldn't plot be
enough in both cases?

Many thanks.

I'm using:
GNU Octave, version 3.0.0
Gnuplot Version 4.2 patchlevel 2

--
Giovanni Di Stasi, Junior Researcher
Dipartimento di Informatica e Sistemistica
Università degli Studi di Napoli "Federico II"
Via Claudio, 21 - 80125 Napoli - Italy

Phone:    +39 081 7683821
Fax:      +39 081 7683816
E-mail:   [hidden email]

_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: plotting while preserving some properties

David Bateman-3
Giovanni Di Stasi wrote:

> Hi,
>
> I am using Octave and Gnuplot in order to draw a "moving" graph; I'm doing
> that by calling repeatedly plot(X) and replot() with the new matrix; Between
> a plot and the next, I'd like the title, the ylabel and the xlabel to be
> preserved (without having to call title(...), xlabel(...) and ylabel(...)
> every time). How can I do that?
>
> Another question: I call my script from bash (I made it executable and put
> #! /usr/bin/octave -qf at the beginning) and, as I said above, I have to call
> both plot and replot (If I just call plot, the figure won't even show up),
> whilst, in the Octave command line, plot is sufficient. Shouldn't plot be
> enough in both cases?
>
> Many thanks.
>
> I'm using:
> GNU Octave, version 3.0.0
> Gnuplot Version 4.2 patchlevel 2
>
>  
 
In the repository this can be done with something like

           x = 0:0.1:10;
           y = sin (x);
           plot (x, y, "ydatasource", "y");
           xlabel ("x");
           ylabel("y");
           title ("This is a moving plot");
           for i = 1 : 100
             pause(0.1)
             y = sin (x + 0.1 * i);
             refreshdata();
           endfor

though not in 3.0.x. For 3.0.x you can try something like

           x = 0:0.1:10;
           y = sin (x);
           h = plot (x, y);
           xlabel ("x");
           ylabel("y");
           title ("This is a moving plot");
           for i = 1 : 100
             drawnow ();
             pause(0.1)
             y = sin (x + 0.1 * i);
             set (h, "ydata", y);
           endfor

D.




--
David Bateman                                [hidden email]
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax)

The information contained in this communication has been classified as:

[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary

_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: plotting while preserving some properties

Michael Goffioul
In reply to this post by Giovanni Di Stasi
On Thu, Sep 4, 2008 at 11:50 AM, Giovanni Di Stasi
<[hidden email]> wrote:
> Hi,
>
> I am using Octave and Gnuplot in order to draw a "moving" graph; I'm doing
> that by calling repeatedly plot(X) and replot() with the new matrix; Between
> a plot and the next, I'd like the title, the ylabel and the xlabel to be
> preserved (without having to call title(...), xlabel(...) and ylabel(...)
> every time). How can I do that?

h = plot (...);
xlabel (...);
ylabel (...);
hold on;
drawnow ();
while (...)
  delete (h);
  h = plot (...);
  drawnow ();
endwhile

> Another question: I call my script from bash (I made it executable and put
> #! /usr/bin/octave -qf at the beginning) and, as I said above, I have to call
> both plot and replot (If I just call plot, the figure won't even show up),
> whilst, in the Octave command line, plot is sufficient. Shouldn't plot be
> enough in both cases?

No, because octave actually sends data to gnuplot on the next drawnow
call. This is called automatically before printing the octave prompt. When you
use octave in bash script, the prompt is never used, so you have to call
drawnow manually.

Michael.
_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave