在Jfree图表的极坐标图中显示刻度线

时间:2019-09-06 07:45:59

标签: java jfreechart

我正在使用Java中的jfree库在极坐标图中工作。我需要在极坐标图中显示“半径刻度”。我以前曾在jfree折线图中工作过,但在极坐标图中却是新来的。

我需要像这样:

Image of the chart

1 个答案:

答案 0 :(得分:1)

here所示,通常使用径向PolarPlot创建Axis。默认情况下,轴上的刻度标签是可见的,ChartFactory.createPolarChart()将其禁用:

rangeAxis.setTickMarksVisible(false);

如果您是使用工厂创建的图表,只需启用刻度线即可:

PolarPlot plot = (PolarPlot) chart.getPlot();
ValueAxis axis = plot.getAxis();
axis.setTickLabelsVisible(true);

或者,您自己创建图,如here所示,并启用刻度标签:

ValueAxis radiusAxis = new NumberAxis();
…
PolarPlot plot = new PolarPlot(dataset, radiusAxis, renderer);

polar plot with radial tick labels