rst
rst

Reputation: 2724

Set number of angular grid lines to a fixed value for a PolarPlot with jfreechart

I'm facing an issue using PolarPlot with jFreeChart. My code plots a single dot with an arbitrary angle and a radius of maximum 1. Everytime I redraw the plot, the number of radial grid lines changes. This makes the program very ugly. Example of different number of grid lines

How can I constrain the number of lines to a predefined number?

Upvotes: 1

Views: 136

Answers (1)

rst
rst

Reputation: 2724

So I found a satisfying solution:

final JFreeChart chart = ChartFactory.createPolarChart("", dataset, true, true, false);
final PolarPlot plot = (PolarPlot) chart.getPlot();
((NumberAxis)plot.getAxis()).setTickUnit(new NumberTickUnit(0.25));
plot.getAxis().setRange(-1, 1);

Important is the last line, where you set the Range, else if you only plot one single dot the spacing is correct, but the plot will be scaled and the plotted dot lies on the border.

Upvotes: 1

Related Questions