log axis auto scaling problem

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
arwelbath
Posts: 24
Joined: Fri Aug 10, 2007 12:37 pm

log axis auto scaling problem

Post by arwelbath » Fri Jun 04, 2010 3:13 pm

Hi,
I am plotting a number of series on a log-log XY plot, and I have a problem with autoscaling.
If I zoom in, the data looks fine. However, if I zoom out, the y-axis automatically scales so that its lowest value is 10e-101.
This problem is iontermittent and only occurs with some datasets. Any idea how I can control the autoscale limits of my axis??

Code: Select all


        public ChartPanel mkRefErrorBarChart(XYIntervalSeriesCollection pointsColl, XYSeriesCollection linesColl, String name) {
        
        linesColl.setIntervalWidth(0.0);
        
        LogAxis yAxisLog = new LogAxis("Ref");
        yAxisLog.setNumberFormatOverride(new LogFormat(10.0, "10e", true));
        
        //Make the symbols plot....
        XYErrorRenderer rendererPoints = new XYErrorRenderer();
        rendererPoints.setShapesVisible(true);
        rendererPoints.setShapesFilled(false);
        rendererPoints.setLinesVisible(false);
        
        //Make the lines plot....
        XYLineAndShapeRenderer rendererLines = new XYLineAndShapeRenderer();
        rendererLines.setLinesVisible(true);
        rendererLines.setShapesVisible(false);
        
        XYPlot plot = new XYPlot(pointsColl, refXAxisLog, yAxisLog, rendererPoints);
        
        plot.setDataset(1,linesColl);
        plot.setRenderer(1,rendererLines);
        
        plot.setBackgroundPaint(Color.white);
        plot.setDomainGridlinesVisible(false);
        plot.setRangeGridlinesVisible(false);
        
        JFreeChart chart = new JFreeChart("", plot);
        chart.removeLegend();
        chart.getPlot().setDrawingSupplier(new DefaultDrawingSupplier(
                    new Paint[] {VERY_DARK_RED, 
                    VERY_DARK_GREEN,
                    VERY_DARK_BLUE,
                    VERY_DARK_MAGENTA,
                    VERY_DARK_YELLOW,
                    DARK_RED, 
                    DARK_GREEN,
                    DARK_BLUE,
                    DARK_MAGENTA},
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); 
        
        final ChartPanel panel = new ChartPanel(chart);
        panel.getChartRenderingInfo().setEntityCollection(null);
        panel.setDisplayToolTips(false);
        this.refChart = chart;
        return panel;
    }


paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: log axis auto scaling problem

Post by paradoxoff » Sat Jun 05, 2010 11:17 am

Does

Code: Select all

LogAxis.setSmallestValue(0.1)
work?
I assume that you have items in your dataset with zero or negative y values, and the LogAxis then lifts the lower bound up to something that it can visualize (which is this smallestValue, for which the default is 1E-100).

Locked