JFreeChart无法删除绘图范围内的图形线

时间:2017-05-17 20:51:53

标签: java graphics jfreechart

我有一个问题,当程序使用"限制""

绘制图形时

我的图片

Graphic with limit's

但我需要这样的东西

image

一段代码,我绘制图形:

private XYSeries series;
double R0 = -40;
double A = 20;
series = new XYSeries("r(fi) = " + R0 +" + (" + A + "*cos(fi*3))",false);

addCoordinates(0.01,20,20);

XYDataset xyDataset = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createXYLineChart("my graphic 14",
        "x", "y", xyDataset, PlotOrientation.VERTICAL,
        true, true, true);

private void addCoordinates(double step, double rangeX, double rangeY){
    series.clear();
    for (double fi=0; fi < 2*Math.PI; fi+=step) {
        double ro = R0 + A * Math.cos(fi * 3);
        double x = ro * Math.cos(fi);
        double y = ro * Math.sin(fi);
        if(Math.abs(x) <= rangeX && Math.abs(y) <=rangeY) series.add(x,y);

    }
}

0 个答案:

没有答案