0

I've been working on these histograms for a while and for some images the histograms work fine. (sorry i can't post images yet)but for other images some bars shoot up while the other stay really low.

My Question: How to make the bars that are relatively low to become more noticeable or at least make sure that we can see the shape of the graph instead of red lines close to x-axis. I used both bar and histogram graphs in jfreechart but still didn't work. It was same for both.

/* bar graph java code */
    public class BarExample1 extends ApplicationFrame {
        public BarExample1(String title) {
        super(title);
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        ImageHistogram im = new ImageHistogram();
        im.getHistogram();
        for(int i=0;i<256;i++)
            dataset.addValue(im.grp[i], "1", ""+i);
        JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo", // chart
                                                                            // title
                "Category", // domain axis label
                "Value", // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                true, // include legend
                true, // tooltips?
                false // URLs?
        );
        CategoryPlot plot = chart.getCategoryPlot();
        BarRenderer renderer = (BarRenderer) plot.getRenderer();
        renderer.setSeriesPaint(0, Color.red);
        renderer.setSeriesPaint(1, Color.gray);
        renderer.setDrawBarOutline(false);
        renderer.setItemMargin(0.1);
        renderer.setMinimumBarLength(0.05);
        renderer.setMaximumBarWidth(0.1);
        ChartPanel chartPanel = new ChartPanel(chart, false);
        chartPanel.setPreferredSize(new Dimension(700, 400));
        setContentPane(chartPanel);


    }
    public static void main(String[] args) {
        BarExample1 demo = new BarExample1("Bar Demo 1");

        demo.pack();
        RefineryUtilities.centerFrameOnScreen(demo);
        demo.setVisible(true);
    }
}
  • That's up to you, you could have a "lower" limit, for which values which fall below it will be rendered to instead – MadProgrammer Apr 12 '17 at 23:42
  • how can we set a lower limit? is there an example you could share? – Harry Coder Apr 12 '17 at 23:45
  • An `if` statement? Sorry, just realised you're using `JFreeChart` :P - You may need to manipulate your data to generate the results you're looking for – MadProgrammer Apr 12 '17 at 23:46
  • That's really hard because we don't know whats in there until you see the graph. – Harry Coder Apr 12 '17 at 23:55
  • 1
    Be sure to enable zooming, for [example](http://stackoverflow.com/a/28519356/230513), and consider adding zoom controls such as [these](http://stackoverflow.com/a/41544007/230513). – trashgod Apr 13 '17 at 00:29

0 Answers0