Hi all,
I'd like to produce a scatter plot with date data on the vertical axis. TimeSeriesChart appears to only support date on the horizontal axis. Can this be overridden? Or should I just work from an XYChart?
thanks in advance,
Ian
Vertical date axis on TimeSeriesChart
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
You can just replace the range axis (which is, by default, a NumberAxis) with a new DateAxis:
Note that the y-values from your dataset will now be interpreted as "milliseconds since 1-Jan-1970" as in java.util.Date.
Code: Select all
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRangeAxis(new DateAxis("Date"));
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


thanks for coming back to me David,
Unfortunately I omitted to indicate that I wish to show my 'range' data (distance in this instance) along the horizontal axis. Extending from your example, I would replace the domain axis with a NumberAxis. At this point, would it have just been better to start with an XYPlot?
cheers,
Ian
Unfortunately I omitted to indicate that I wish to show my 'range' data (distance in this instance) along the horizontal axis. Extending from your example, I would replace the domain axis with a NumberAxis. At this point, would it have just been better to start with an XYPlot?
cheers,
Ian
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
OK, is the date axis for your y-values? If yes, and you want the y-values along the horizontal axis, then you can call plot.setOrientation(PlotOrientation.HORIZONTAL). This switches the orientation of the plot, so that the x-axis is the vertical axis and the y-axis is the horizontal axis.
Note that in JFreeChart domainAxis == xAxis and rangeAxis == yAxis. And also, a time series chart *is* an XYPlot, but one that has had its xAxis changed from a NumberAxis to a DateAxis (there's nothing to stop you from changing it back to a NumberAxis again).
Note that in JFreeChart domainAxis == xAxis and rangeAxis == yAxis. And also, a time series chart *is* an XYPlot, but one that has had its xAxis changed from a NumberAxis to a DateAxis (there's nothing to stop you from changing it back to a NumberAxis again).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

