Hello everybody,
Is there anybody who know , how should I do to put my axis' TickLabels in Exponantial Format?
200000 =>2E5
100000 =>1E5
10000 =>1E4
How to put the Label of my TickLabels in exponential format
Re: How to put the Label of my TickLabels in exponential format
Actually I've found a method to format a double in exponantial:
NumberFormat formatter = new DecimalFormat("0E0");
String s = formatter.format(-1234.567); // -1E3
However the method add(x,y) of XYSeries doesn't accept String as parameters!!!
NumberFormat formatter = new DecimalFormat("0E0");
String s = formatter.format(-1234.567); // -1E3
However the method add(x,y) of XYSeries doesn't accept String as parameters!!!
Re: How to put the Label of my TickLabels in exponential format
You should not be formatting the number before you add them to the chart, you Axis class should be formatting them. If you do not like the default formatting you can override the default numberformat by callling the axis setNUmberFormatOverride method, like this:
Of course you can use whatever Axis you prefer, or even write you own 
If you used the ChartFactory then probably you have a JFreeChart chart variable, in that case you can do:
Code: Select all
NumberAxis xAxis = new NumberAxis();
xAxis.setNumberFormatOverride(new DecimalFormat("0E0"));

If you used the ChartFactory then probably you have a JFreeChart chart variable, in that case you can do:
Code: Select all
//JFreeChart chart
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis xAxis = new NumberAxis();
xAxis.setNumberFormatOverride(new DecimalFormat("0E0"));
plot.setDomainAxis(xAxis);
Creator of Glotaran, a software program developed for global and target analysis of time-resolved spectroscopy and microscopy data. Big fan of JFreeChart.
Re: How to put the Label of my TickLabels in exponential format
Thank you for answering!!!
That' s exactly what i needed!
That' s exactly what i needed!