Flipped XYPlot

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
vinod

Flipped XYPlot

Post by vinod » Wed Jun 26, 2002 7:22 pm

Is there an easy way to switch the axes on an XYPlot? What I want is this:

I have pairs of data with the "X' values being depths and the "Y" values
some other property which changes which depth. I want the depth to be
on the vertical axis and the property on the horizontal axis.

Switching the X and Y axes when creating the plot doesn't work (throws an exception). Switching the data doesn't give the result that I want.
To give an better idea of what I want, on the samples page there is a "Time Series Chart" with the "Date" on the x axis and the "CCP per GBP" on the y axis. I want the same chart with the "Date" on the y axis and the "CCP per GBP" on the x axis. So the actualy "curve" will look the same but rotated 90 degrees.
I'm looking specifically for a solution using XYPlot

Thanks

David Gilbert

Re: Flipped XYPlot

Post by David Gilbert » Wed Jun 26, 2002 11:15 pm

Hi,

There's only one orientation for XYPlot (domain on the horizontal axis, range on the vertical axis). It wouldn't be that difficult to implement a version the other way around (analogous to HorizontalCategoryPlot and VerticalCategoryPlot)...perhaps it should be called YXPlot. I never wrote this because I couldn't think of an application for it (although it sounds like you have one).

Actually, it probably isn't necessary to write another plot class...it is probably enough to write alternative versions of the XYItemRenderer classes that use the Y axis for the domain and the X axis for the range.

This would be an interesting extension for JFreeChart, although I don't have time to work on it right now...I'm happy to accept code contributions though!

Regards,

DG.

vinod

Re: Flipped XYPlot

Post by vinod » Fri Jun 28, 2002 6:11 pm

There is also another "solution" to what I want: using a YXSeries instead
of an XYSeries
My first idea for this problem was to specify the data in the increasing/decreasing order of the Y coordinate. I thought the data values I specify will be stored in the order specified. But the data values in the XYSeries class are stored in increasing order of the X coordinate, so the order in which I add the values made no difference.
I haven't looked at all the classes yet, but is there another class which can be used as the data source for the XYPlot which will not impose an ordering by itself but will simply use the order in which the values are added?
If nothing is available, I will implement one of the solutions by simply extending the existing class and overriding the necessary methods. I'll be more than happy to contribute the code for future use, but I can't guarantee that it will conform to any coding standards :-)

Vinod

Locked