ImageJ Plot other than line

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

ImageJ Plot other than line

GeraldT
Hi,

I want to do some plots using for example x-shaped marks. I understand that I have to use addPoints(float[] x, float[] y, int shape) to an existing Plot object. The problem is that if I am creating an empty Plot object, e.g.

Plot plot = new Plot("Title", "x-label", "y-label");
plot.addPoints(x, y, Plot.X); // x and y beeing arrays containing function
plot.show();

Then it does not work, even if I set min and max to the axes. The plotwindow is empty and NaN is shown on both axes near the origin. Googling the problem I found an solution, the plot has to be initialised as:

Plot plot = new Plot("Title", "x-label", "y-label", new double[0], new double[0]);

Then it works, but actually the plot contains two functions after adding the points. Is there a way to avoid that?

Thank you :-)

Mvh

Gerald R. Torgersen
IT-seksjonen,
Det odontologiske fakultet / Faculty of Dentistry
Universitetet i Oslo / University of Oslo

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

Re: ImageJ Plot other than line

Rasband, Wayne (NIH/NIMH) [E]
On Mar 15, 2013, at 4:56 AM, Gerald Ruiner Torgersen wrote:

> Hi,
>
> I want to do some plots using for example x-shaped marks. I understand that I have to use addPoints(float[] x, float[] y, int shape) to an existing Plot object. The problem is that if I am creating an empty Plot object, e.g.
>
> Plot plot = new Plot("Title", "x-label", "y-label");
> plot.addPoints(x, y, Plot.X); // x and y beeing arrays containing function
> plot.show();
>
> Then it does not work, even if I set min and max to the axes. The plotwindow is empty and NaN is shown on both axes near the origin. Googling the problem I found an solution, the plot has to be initialised as:
>
> Plot plot = new Plot("Title", "x-label", "y-label", new double[0], new double[0]);
>
> Then it works, but actually the plot contains two functions after adding the points. Is there a way to avoid that?
You have to set the plot limits. Here is an example:

   float[] x = {0.1f, 1f, 2f, 3f, 4f, 4.9f};
   float[] y = {0.3f, 1.1f, 2.3f, 2.8f, 1.4f, 0.5f};
   Plot plot = new Plot("Plot", "X", "Y");
   plot.setFrameSize(500,200);
   plot.setLimits(0, 5, 0, 3);
   plot.setLineWidth(2);
   plot.setColor(Color.red);
   plot.addPoints(x, y, Plot.X);
   plot.show();

[cid:[hidden email]]




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

plot.jpg (36K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ Plot other than line

GeraldT
On 17.03.2013 08:05, Rasband, Wayne (NIH/NIMH) [E] wrote:

> On Mar 15, 2013, at 4:56 AM, Gerald Ruiner Torgersen wrote:
>
>> Hi,
>>
>> I want to do some plots using for example x-shaped marks. I understand that I have to use addPoints(float[] x, float[] y, int shape) to an existing Plot object. The problem is that if I am creating an empty Plot object, e.g.
>>
>> Plot plot = new Plot("Title", "x-label", "y-label");
>> plot.addPoints(x, y, Plot.X); // x and y beeing arrays containing function
>> plot.show();
>>
>> Then it does not work, even if I set min and max to the axes. The plotwindow is empty and NaN is shown on both axes near the origin. Googling the problem I found an solution, the plot has to be initialised as:
>>
>> Plot plot = new Plot("Title", "x-label", "y-label", new double[0], new double[0]);
>>
>> Then it works, but actually the plot contains two functions after adding the points. Is there a way to avoid that?
> You have to set the plot limits. Here is an example:
>
>     float[] x = {0.1f, 1f, 2f, 3f, 4f, 4.9f};
>     float[] y = {0.3f, 1.1f, 2.3f, 2.8f, 1.4f, 0.5f};
>     Plot plot = new Plot("Plot", "X", "Y");
>     plot.setFrameSize(500,200);
>     plot.setLimits(0, 5, 0, 3);
>     plot.setLineWidth(2);
>     plot.setColor(Color.red);
>     plot.addPoints(x, y, Plot.X);
>     plot.show();
>
> [cid:[hidden email]]
>
>
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
Thank you Wayne,

that worked very well :-) Maybee the example should be includet in the
documentation of the class? I googled a lot but did not find any solution.

Regards Gerald

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

Re: ImageJ Plot other than line

CARL Philippe (LBP)
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
Dear Wayne and Johannes,
I have worked some months ago on a plugin for which I needed the extension of the Plot class in order to extend its functionalitytowards accepting ArrayList data input and allowing to display arrow plots, logarithmic (log in x and/or y) plots, minor ticks (decimal andlogarithmic), change of the label font, draw dotted lines...
If you think these implementations could be interresting for the community and thus be integrated in the native ImageJ code, I have attached the corresponding code.
Kindest regards,
Philippe

Le Dimanche 17 Mars 2013 08:05 CET, "Rasband, Wayne (NIH/NIMH) [E]" <[hidden email]> a écrit:

> On Mar 15, 2013, at 4:56 AM, Gerald Ruiner Torgersen wrote:
>
> > Hi,
> >
> > I want to do some plots using for example x-shaped marks. I understand that I have to use addPoints(float[] x, float[] y, int shape) to an existing Plot object. The problem is that if I am creating an empty Plot object, e.g.
> >
> > Plot plot = new Plot("Title", "x-label", "y-label");
> > plot.addPoints(x, y, Plot.X); // x and y beeing arrays containing function
> > plot.show();
> >
> > Then it does not work, even if I set min and max to the axes. The plotwindow is empty and NaN is shown on both axes near the origin. Googling the problem I found an solution, the plot has to be initialised as:
> >
> > Plot plot = new Plot("Title", "x-label", "y-label", new double[0], new double[0]);
> >
> > Then it works, but actually the plot contains two functions after adding the points. Is there a way to avoid that?
>
> You have to set the plot limits. Here is an example:
>
>    float[] x = {0.1f, 1f, 2f, 3f, 4f, 4.9f};
>    float[] y = {0.3f, 1.1f, 2.3f, 2.8f, 1.4f, 0.5f};
>    Plot plot = new Plot("Plot", "X", "Y");
>    plot.setFrameSize(500,200);
>    plot.setLimits(0, 5, 0, 3);
>    plot.setLineWidth(2);
>    plot.setColor(Color.red);
>    plot.addPoints(x, y, Plot.X);
>    plot.show();
>
> [cid:[hidden email]]
>
>
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html




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

DataPlotWindow.java (19K) Download Attachment
ProfileDataPlot.java (10K) Download Attachment
DataPlot.java (35K) Download Attachment