Berti
Berti

Reputation: 51

How to change from linear to logarithmic axis in XChart?

I am using java to manipulate statistical data in XChart.

I have the charts working but they are using linear scales.

The charts work but the data would be better represented with a logarithmic scale on the y axis.

I have looked online and cannot find any reference as to whether there is a command that can convert the x or y axis to logarithmic rather than linear...

My data is clustered between 1 and 10 but there are a few values that go over 1000....I want to be able to represent all of the points on the chart.

Upvotes: 2

Views: 396

Answers (1)

AnyTimeTraveler
AnyTimeTraveler

Reputation: 81

I just looked at the documentation and found this AxesChartStyler.
Then I opened my IDE and upon typing myChart.sty, it suggested getStyler() to me, which indeed gives you the correct styler.

The code you need to enable logarithmic axis is this:

XYChart myChart = new XYChart(500, 500);

myChart.getStyler().setXAxisLogarithmic(true);
myChart.getStyler().setYAxisLogarithmic(true);

You cannot use logarithmic axis with negative values for some reason.

Upvotes: 1

Related Questions