Is it possible to add new data to a plot from a macro?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Is it possible to add new data to a plot from a macro?

JimmiB
Dear all,
I am making certain measurements as i go through a macro and would like to
add these data to a single plot.
I am I correct in thinking that to create a plot and modify it all plot
commands must be in a single group?

For example this works
Plot.create("event profile", "Slice", "Intensity");
Plot.setLimits(0, nslices, gmin, gmax);
Plot.add("line",x, y);
Plot.show();

but if i then repopulate y

Plot.add("line",x, y);
Plot.show();

This will not work.

Is there a simple work around?

Thanks in advance,
James


*Dr James Burchfield*
The Garvan Institute of Medical Research
384 Victoria Street
Darlinghurst, NSW, 2010
Australia

Email: [hidden email]
Phone:+61 2 92958229
Web: *www.garvan.org.au <http://www.garvan.org.au>*

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to add new data to a plot from a macro?

lechristophe
Hi James,

You have to use Plot.show() at the end, after adding all data with
Plot.add().
Once shown, the graph can't be updated.

Christophe


2014-02-11 12:14 GMT+01:00 James Burchfield <[hidden email]>:

> Dear all,
> I am making certain measurements as i go through a macro and would like to
> add these data to a single plot.
> I am I correct in thinking that to create a plot and modify it all plot
> commands must be in a single group?
>
> For example this works
> Plot.create("event profile", "Slice", "Intensity");
> Plot.setLimits(0, nslices, gmin, gmax);
> Plot.add("line",x, y);
> Plot.show();
>
> but if i then repopulate y
>
> Plot.add("line",x, y);
> Plot.show();
>
> This will not work.
>
> Is there a simple work around?
>
> Thanks in advance,
> James
>
>
> *Dr James Burchfield*
> The Garvan Institute of Medical Research
> 384 Victoria Street
> Darlinghurst, NSW, 2010
> Australia
>
> Email: [hidden email]
> Phone:+61 2 92958229
> Web: *www.garvan.org.au <http://www.garvan.org.au>*
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to add new data to a plot from a macro?

Michael Doube-4
Hi James,

> You have to use Plot.show() at the end, after adding all data with
> Plot.add().
> Once shown, the graph can't be updated.

But, the ImageProcessor which is displaying the plot can be updated with a new Plot's data.

It might not be so simple for you to implement but that is the approach we took in BoneJ's Anisotropy plugin, which shows a live updating line plot with error bars and auto-scaling x axis. See createGraph() and updateGraph() here:

https://github.com/mdoube/BoneJ/blob/master/src/org/doube/bonej/Anisotropy.java#L365
https://github.com/mdoube/BoneJ/blob/master/src/org/doube/bonej/Anisotropy.java#L634

Not sure how you would do this in the macro language, however.

Michael

> 2014-02-11 12:14 GMT+01:00 James Burchfield <[hidden email]>:
>
>> Dear all,
>> I am making certain measurements as i go through a macro and would like to
>> add these data to a single plot.
>> I am I correct in thinking that to create a plot and modify it all plot
>> commands must be in a single group?
>>
>> For example this works
>> Plot.create("event profile", "Slice", "Intensity");
>> Plot.setLimits(0, nslices, gmin, gmax);
>> Plot.add("line",x, y);
>> Plot.show();
>>
>> but if i then repopulate y
>>
>> Plot.add("line",x, y);
>> Plot.show();
>>
>> This will not work.
>>
>> Is there a simple work around?
>>
>> Thanks in advance,
>> James
>>
>>
>> *Dr James Burchfield*
>> The Garvan Institute of Medical Research
>> 384 Victoria Street
>> Darlinghurst, NSW, 2010
>> Australia
>>
>> Email: [hidden email]
>> Phone:+61 2 92958229
>> Web: *www.garvan.org.au <http://www.garvan.org.au>*
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

<http://www.rvc.ac.uk>

This message, together with any attachments, is intended for the stated addressee(s) only and may contain privileged or confidential information. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Royal Veterinary College.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to add new data to a plot from a macro?

JimmiB
In reply to this post by lechristophe
Awesome, I am now creating beautiful multi-colour graphs.
Much appreciated.
Do you know what the difference then is between
Plot.show();
Plot.update();
Cheers,
James



*Dr James Burchfield*
The Garvan Institute of Medical Research
384 Victoria Street
Darlinghurst, NSW, 2010
Australia

Email: [hidden email]
Phone:+61 2 92958229
Web: *www.garvan.org.au <http://www.garvan.org.au>*


On Tue, Feb 11, 2014 at 10:24 PM, Christophe Leterrier <
[hidden email]> wrote:

> Hi James,
>
> You have to use Plot.show() at the end, after adding all data with
> Plot.add().
> Once shown, the graph can't be updated.
>
> Christophe
>
>
> 2014-02-11 12:14 GMT+01:00 James Burchfield <[hidden email]>:
>
> > Dear all,
> > I am making certain measurements as i go through a macro and would like
> to
> > add these data to a single plot.
> > I am I correct in thinking that to create a plot and modify it all plot
> > commands must be in a single group?
> >
> > For example this works
> > Plot.create("event profile", "Slice", "Intensity");
> > Plot.setLimits(0, nslices, gmin, gmax);
> > Plot.add("line",x, y);
> > Plot.show();
> >
> > but if i then repopulate y
> >
> > Plot.add("line",x, y);
> > Plot.show();
> >
> > This will not work.
> >
> > Is there a simple work around?
> >
> > Thanks in advance,
> > James
> >
> >
> > *Dr James Burchfield*
> > The Garvan Institute of Medical Research
> > 384 Victoria Street
> > Darlinghurst, NSW, 2010
> > Australia
> >
> > Email: [hidden email]
> > Phone:+61 2 92958229
> > Web: *www.garvan.org.au <http://www.garvan.org.au>*
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to add new data to a plot from a macro?

JimmiB
In reply to this post by Michael Doube-4
Thanks Michael,
If I ever move beyond macros, I am sure this will prove useful.



*Dr James Burchfield*
The Garvan Institute of Medical Research
384 Victoria Street
Darlinghurst, NSW, 2010
Australia

Email: [hidden email]
Phone:+61 2 92958229
Web: *www.garvan.org.au <http://www.garvan.org.au>*


On Wed, Feb 12, 2014 at 2:46 AM, Doube, Michael <[hidden email]> wrote:

> Hi James,
>
> > You have to use Plot.show() at the end, after adding all data with
> > Plot.add().
> > Once shown, the graph can't be updated.
>
> But, the ImageProcessor which is displaying the plot can be updated with a
> new Plot's data.
>
> It might not be so simple for you to implement but that is the approach we
> took in BoneJ's Anisotropy plugin, which shows a live updating line plot
> with error bars and auto-scaling x axis. See createGraph() and
> updateGraph() here:
>
>
> https://github.com/mdoube/BoneJ/blob/master/src/org/doube/bonej/Anisotropy.java#L365
>
> https://github.com/mdoube/BoneJ/blob/master/src/org/doube/bonej/Anisotropy.java#L634
>
> Not sure how you would do this in the macro language, however.
>
> Michael
>
> > 2014-02-11 12:14 GMT+01:00 James Burchfield <[hidden email]
> >:
> >
> >> Dear all,
> >> I am making certain measurements as i go through a macro and would like
> to
> >> add these data to a single plot.
> >> I am I correct in thinking that to create a plot and modify it all plot
> >> commands must be in a single group?
> >>
> >> For example this works
> >> Plot.create("event profile", "Slice", "Intensity");
> >> Plot.setLimits(0, nslices, gmin, gmax);
> >> Plot.add("line",x, y);
> >> Plot.show();
> >>
> >> but if i then repopulate y
> >>
> >> Plot.add("line",x, y);
> >> Plot.show();
> >>
> >> This will not work.
> >>
> >> Is there a simple work around?
> >>
> >> Thanks in advance,
> >> James
> >>
> >>
> >> *Dr James Burchfield*
> >> The Garvan Institute of Medical Research
> >> 384 Victoria Street
> >> Darlinghurst, NSW, 2010
> >> Australia
> >>
> >> Email: [hidden email]
> >> Phone:+61 2 92958229
> >> Web: *www.garvan.org.au <http://www.garvan.org.au>*
> >>
> >> --
> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> <http://www.rvc.ac.uk>
>
> This message, together with any attachments, is intended for the stated
> addressee(s) only and may contain privileged or confidential information.
> Any views or opinions presented are solely those of the author and do not
> necessarily represent those of the Royal Veterinary College.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html