I use JFreeChart to create a candlestick chart. The horizontal axis is a DateAxis to indicate the time, the vertical axis is a NumberAxis, to indicate the price. As the screenshot shows, is the price axis shown on the left hand side of the chart.
I would like the vertical axis to be displayed on the right hand side of the chart, instead of the left hand side. I have been looking in the class overview for NumberAxis, ValueAxis and Axis classes in JFreeChart but could not find a method which can make this modification. Can somebody please show me how to make this change?
As shown here, you can use the XYPlot
method setRangeAxisLocation()
to set the location of the primary range axis. The image below illustrates the effect of the following addition to this example:
chart.getXYPlot().setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);