0

How to format x axis labels? I have a chart(look at attach1) attache1 I need to change x axis labels to the labels in the next attach (but with the same chart) attach2

Dmitry
  • 73
  • 2
  • 11

1 Answers1

3

To set the label of the axis (in your example "counts") call

XYPlot plot = (XYPlot) chart.getPlot();
plot.getDomainAxis().setLabel("counts");

To change the number format of the axis call

XYPlot plot = (XYPlot) chart.getPlot();
((NumberAxis)plot.getDomainAxis()).setNumberFormatOverride(new DecimalFormat("0"));

To change the visible range of the plot call

XYPlot plot = (XYPlot) chart.getPlot();
((NumberAxis)plot.getDomainAxis()).setRange(0,20);
Uli
  • 1,390
  • 1
  • 14
  • 28
  • Does that answer your question? In such a case please mark your question as resolved. Thanks! – Uli Feb 04 '15 at 08:43