Posted by
Michael Schmid on
Nov 13, 2008; 10:41am
URL: http://imagej.273.s1.nabble.com/ij-gui-Plot-enhancement-request-tp3694518p3694520.html
Hi Woody,
yes, I agree, the Plot class stores only one set of data, it is the
data that you submit with the constructor. Everything that you add
later is plotted (in the sequence that you add it) but not stored as
data. Finally, with Plot.show() [or in a java program, plot.show()]
the data submitted with the constructor are plotted with the current
color and line type settings, but always as a line.
Plot.draw calls drawPolyline, not addPoints, so there is no way out
with the current version of ImageJ (sorry, Jerome, your version won't
let you list the data)
It is not so clear what could be a good solution.
- Storing all data and listing them in separate columns?
This has the disadvantage that auxiliary lines such as your diagonal
or a horizontal line plotted to show the x axis (at y=0 for plots
with positive and negative values) would generate extra data in the
list.
Also, it might break existing macros or procedures relying on getting
only one y column of data.
- Adding a Plot.setShape(shape) method and calling addPoints instead
of drawPolyline in Plot.draw?
This would perpetuate the counterintuitive problem that you have to
set the shape, line width and color for the data passed in the
constructor after all the other addPoints methods.
- Passing shape, size/lineWidth and color of the initial data with
the constructor?
This would add at least two very long constructors (for float and
double arrays).
public Plot(String title, String xLabel, String yLabel, double[]
xValues, double[] yValues, int flags, int shape, int lineWidth, Color
color)
Also not extremely elegant...
Any better idea?
Michael
________________________________________________________________
On 13 Nov 2008, at 08:14, Jerome Mutterer wrote:
> Unintuitively, the last serie added to a plot is drawn first. Add
> the line
> reference after your data points, and the list button will list
> your points.
>
> Jerome.
>
> Plot.add("dots", x, y);
> Plot.add("line", newArray(0,x.length),newArray(0,y.length));
>
> On Thu, Nov 13, 2008 at 7:32 AM, Jeffrey B. Woodward <
>
[hidden email]> wrote:
>
>> ImageJ'ers/Wayne,
>>
>> I am trying to use the ij.gui.Plot class to create a scatter plot.
>> Actually, the Plot contains both a scatter plot and a simple curve
>> (diagonal
>> line with points at [0,0] and [max,max]). The diagonal line is
>> just for a
>> visual reference; the real data points are what make up the
>> scatter plot.
>> The issue is that in doing this, I can't find a way for the user
>> to use the
>> List button (or the Save button) to get a listing of the data
>> points. This
>> is because the List/Save buttons seem only appear to operate on
>> the points
>> used in the constructor (in my case the endpoints of the reference
>> diagonal), but my data points for the scatter plot are added after
>> construction using the addPoints() method.
>>
>> My first thought was to supply my scatter plot points in the
>> constructor
>> and add the reference line with the addPoints() method; however, I
>> don't see
>> any way to avoid drawing them as a polyline doing it this way -- I
>> want a
>> scatter plot of those points, not a polyline!
>>
>> Hopefully I am missing something obvious in the API/source code,
>> but in
>> case if I am not, is this an enhancement that the ImageJ community is
>> interested in? Should I take a crack at this myself, or is
>> somebody else
>> interested enough to do it?
>>
>> BTW: I suppose that there may be a hack/workaround for my specific
>> case...perhaps I could supply my points in the constructor drawn
>> with a
>> fully transparent color/invisible-ink, then add the points for my
>> reference
>> diagonal using the addPoints() method with a LINE shape and
>> appropriate
>> color, and lastly, add the scatter plot points [again] with the
>> addPoints()
>> method with a DOT shape and appropriate color. Seems ugly --
>> probably doomed
>> to failure -- other suggestions/hacks/workarounds/free-therapy-
>> sessions are
>> welcome.
>>
>> Many thanks,
>>
>> -Woody
>>