To change the X-axis starting value of graph in Jfreechart

后端 未结 2 1750
孤城傲影
孤城傲影 2021-01-18 16:51

I am calculating histogram of red component of the image and stored it in redhisto[]. The index of the array represent the intensity(0 to 255) and the value represent the n

相关标签:
2条回答
  • 2021-01-18 17:44

    You can change the lower bound of the domain axis and set the series paint as shown below. The default XYBarPainter has a gradient color highlight, so I used a StandardXYBarPainter.

    image

    XYPlot plot = (XYPlot) chart.getPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setLowerBound(0);
    XYBarRenderer r = (XYBarRenderer) plot.getRenderer();
    r.setBarPainter(new StandardXYBarPainter());
    r.setSeriesPaint(0, Color.blue);
    
    0 讨论(0)
  • 2021-01-18 17:54
        XYPlot plot = (XYPlot) chart.getPlot();  
    
        //To change the lower bound of X-axis
        NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
        xAxis.setLowerBound(0);
    
        //To change the lower bound of Y-axis       
        NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
        yAxis.setLowerBound(0);
    
        // To change the color
        XYItemRenderer renderer = plot.getRenderer();
        renderer.setSeriesPaint(0, Color.green);
    
    0 讨论(0)
提交回复
热议问题