Example usage for org.jfree.chart.axis LogarithmicAxis LogarithmicAxis

List of usage examples for org.jfree.chart.axis LogarithmicAxis LogarithmicAxis

Introduction

In this page you can find the example usage for org.jfree.chart.axis LogarithmicAxis LogarithmicAxis.

Prototype

public LogarithmicAxis(String label) 

Source Link

Document

Creates a new axis.

Usage

From source file:org.operamasks.faces.render.graph.ChartRenderer.java

protected void setChartAxes(JFreeChart chart, UIChart comp) {
    UIAxis xAxis = comp.getxAxis();/*from   w ww  .  j av a2 s.com*/
    UIAxis yAxis = comp.getyAxis();
    String xAxisLabel = comp.getxAxisLabel();
    String yAxisLabel = comp.getyAxisLabel();

    Plot plot = chart.getPlot();
    Axis domainAxis = null;
    Axis rangeAxis = null;

    if (plot instanceof CategoryPlot) {
        CategoryPlot categoryPlot = (CategoryPlot) plot;
        if (yAxis != null && yAxis.isLogarithmic())
            categoryPlot.setRangeAxis(new LogarithmicAxis(null));

        domainAxis = categoryPlot.getDomainAxis();
        rangeAxis = categoryPlot.getRangeAxis();

        if (xAxis != null) {
            Boolean drawGridLine = xAxis.getDrawGridLine();
            if (drawGridLine != null) {
                categoryPlot.setDomainGridlinesVisible(drawGridLine);
            }
            Paint gridLineColor = xAxis.getGridLineColor();
            if (gridLineColor != null) {
                categoryPlot.setDomainGridlinePaint(gridLineColor);
            }
        }

        if (yAxis != null) {
            Boolean drawGridLine = yAxis.getDrawGridLine();
            if (drawGridLine != null) {
                categoryPlot.setRangeGridlinesVisible(drawGridLine);
            }
            Paint gridLineColor = yAxis.getGridLineColor();
            if (gridLineColor != null) {
                categoryPlot.setRangeGridlinePaint(gridLineColor);
            }
        }
    } else if (plot instanceof XYPlot) {
        XYPlot xyPlot = (XYPlot) plot;
        if (xAxis != null && xAxis.isLogarithmic())
            xyPlot.setDomainAxis(new LogarithmicAxis(null));
        if (yAxis != null && yAxis.isLogarithmic())
            xyPlot.setRangeAxis(new LogarithmicAxis(null));

        domainAxis = xyPlot.getDomainAxis();
        rangeAxis = xyPlot.getRangeAxis();

        if (xAxis != null) {
            Boolean drawGridLine = xAxis.getDrawGridLine();
            if (drawGridLine != null) {
                xyPlot.setDomainGridlinesVisible(drawGridLine);
            }
            Paint gridLineColor = xAxis.getGridLineColor();
            if (gridLineColor != null) {
                xyPlot.setDomainGridlinePaint(gridLineColor);
            }
            Boolean drawBaseLine = xAxis.getDrawBaseLine();
            if (drawBaseLine != null) {
                xyPlot.setDomainZeroBaselineVisible(drawBaseLine);
            }
            Paint baseLineColor = xAxis.getBaseLineColor();
            if (baseLineColor != null) {
                xyPlot.setDomainZeroBaselinePaint(baseLineColor);
            }
        }

        if (yAxis != null) {
            Boolean drawGridLine = yAxis.getDrawGridLine();
            if (drawGridLine != null) {
                xyPlot.setRangeGridlinesVisible(drawGridLine);
            }
            Paint gridLineColor = yAxis.getGridLineColor();
            if (gridLineColor != null) {
                xyPlot.setRangeGridlinePaint(gridLineColor);
            }
            Boolean drawBaseLine = yAxis.getDrawBaseLine();
            if (drawBaseLine != null) {
                xyPlot.setRangeZeroBaselineVisible(drawBaseLine);
            }
            Paint baseLineColor = yAxis.getBaseLineColor();
            if (baseLineColor != null) {
                xyPlot.setRangeZeroBaselinePaint(baseLineColor);
            }
        }
    }

    if (domainAxis != null) {
        if (xAxisLabel != null)
            domainAxis.setLabel(xAxisLabel);
        if (xAxis != null)
            setAxisStyles(domainAxis, xAxis);
    }
    if (rangeAxis != null) {
        if (yAxisLabel != null)
            rangeAxis.setLabel(yAxisLabel);
        if (yAxis != null)
            setAxisStyles(rangeAxis, yAxis);
    }
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.XYChartExpression.java

protected void configureLogarithmicAxis(final XYPlot plot) {
    if (isLogarithmicAxis()) {
        final LogarithmicAxis logarithmicAxis;
        if (isHumanReadableLogarithmicFormat()) {
            plot.getRenderer().setBaseItemLabelGenerator(new LogXYItemLabelGenerator());
            logarithmicAxis = new ScalingLogarithmicAxis(getRangeTitle());
            logarithmicAxis.setStrictValuesFlag(false);
        } else {/*from   w  w  w . j a  va2 s .  c o m*/
            logarithmicAxis = new LogarithmicAxis(getRangeTitle());
            logarithmicAxis.setStrictValuesFlag(false);
        }

        plot.setRangeAxis(logarithmicAxis);
    }
}

From source file:mil.tatrc.physiology.utilities.csv.plots.ActionEventPlotter.java

public void createGraph(PlotJob job, List<List<Double>> timeData, List<List<Double>> data,
        List<LogEvent> events, List<SEAction> actions) {
    CSVPlotTool plotTool = new CSVPlotTool(); //to leverage existing functions
    String title = job.name + "_";
    XYSeriesCollection dataSet = new XYSeriesCollection();
    double maxY = 0;
    double minY = Double.MAX_VALUE;
    for (int i = 0; i < timeData.size(); i++) {
        if (timeData.get(i) == null || data.get(i) == null) {
            job.bgColor = Color.white; //This hits when we have Expected data but NOT computed data
            continue;
        }/*from   w  ww. j  ava  2 s  .c om*/

        title = title + job.headers.get(i) + "_";
        XYSeries dataSeries;
        if (job.isComparePlot) {
            if (timeData.size() > 1)
                dataSeries = plotTool.createXYSeries(i == 0 ? "Expected" : "Computed", timeData.get(i),
                        data.get(i));
            else //If we're comparing but only have one data list, expected is missing, so rename to computed
            {
                dataSeries = plotTool.createXYSeries("Computed", timeData.get(i), data.get(i));
            }
        } else
            dataSeries = plotTool.createXYSeries(job.headers.get(i), timeData.get(i), data.get(i));
        dataSet.addSeries(dataSeries);
        maxY = maxY < dataSeries.getMaxY() ? dataSeries.getMaxY() : maxY;
        minY = minY > dataSeries.getMinY() ? dataSeries.getMinY() : minY;
    }
    title = title + "vs_Time_Action_Event_Plot";

    //Override the constructed title if desired (usually for compare plots)
    if (job.titleOverride != null && !job.titleOverride.isEmpty()
            && !job.titleOverride.equalsIgnoreCase("None"))
        title = job.titleOverride;

    double rangeLength = maxY - minY;
    if (Math.abs(rangeLength) < 1e-6) {
        rangeLength = .01;
    }

    class AEEntry implements Comparable<AEEntry> {
        public String name;
        public List<Double> times = new ArrayList<Double>();
        public List<Double> YVals = new ArrayList<Double>();
        public String type = "";

        public int compareTo(AEEntry entry) {
            return times.get(0) < entry.times.get(0) ? -1 : times.get(0) > entry.times.get(0) ? 1 : 0;
        }
    }

    List<AEEntry> allActionsAndEvents = new ArrayList<AEEntry>();

    if (!job.skipAllEvents) {
        //Make points for each event
        //Treat each event like two points on the same vertical line
        for (LogEvent event : events) {
            boolean skip = false;

            for (String eventToSkip : job.eventOmissions) {
                if (event.text.contains(eventToSkip))
                    skip = true;
            }
            if (skip)
                continue;
            AEEntry entry = new AEEntry();

            entry.times.add(event.time.getValue());
            if (job.logAxis)
                entry.YVals.add(maxY);
            else if (job.forceZeroYAxisBound && maxY < 0)
                entry.YVals.add(-.01);
            else
                entry.YVals.add(maxY + 0.15 * rangeLength);

            entry.times.add(event.time.getValue());
            if (job.logAxis)
                entry.YVals.add(minY);
            else if (job.forceZeroYAxisBound && minY > 0)
                entry.YVals.add(-.01);
            else
                entry.YVals.add(minY - 0.15 * rangeLength);

            entry.name = event.text + "\r\nt=" + event.time.getValue();
            entry.type = "EVENT:";

            allActionsAndEvents.add(entry);
        }
    }

    if (!job.skipAllActions) {
        //Make similar entries for actions
        for (SEAction action : actions) {
            boolean skip = false;

            for (String actionToSkip : job.actionOmissions) {
                if (action.toString().contains(actionToSkip))
                    skip = true;
            }
            if (skip)
                continue;

            if (action.toString().contains("Advance Time"))
                continue;

            AEEntry entry = new AEEntry();

            entry.times.add(action.getScenarioTime().getValue());
            if (job.logAxis)
                entry.YVals.add(maxY);
            else if (job.forceZeroYAxisBound && maxY < 0)
                entry.YVals.add(-.01);
            else
                entry.YVals.add(maxY + 0.15 * rangeLength);

            entry.times.add(action.getScenarioTime().getValue());
            if (job.logAxis)
                entry.YVals.add(minY);
            else if (job.forceZeroYAxisBound && minY > 0)
                entry.YVals.add(-.01);
            else
                entry.YVals.add(minY - 0.15 * rangeLength);

            entry.name = action.toString() + "\r\nt=" + action.getScenarioTime().getValue();
            entry.type = "ACTION:";

            allActionsAndEvents.add(entry);
        }
    }

    //Sort the list
    Collections.sort(allActionsAndEvents);

    //Add a series for each entry
    for (AEEntry entry : allActionsAndEvents) {
        dataSet.addSeries(plotTool.createXYSeries(entry.type + entry.name, entry.times, entry.YVals));
    }

    //If we have experimental data, try to load it and create a dataset for it
    XYSeriesCollection expDataSet = new XYSeriesCollection();
    if (job.experimentalData != null && !job.experimentalData.isEmpty()) {
        Map<String, List<Double>> expData = new HashMap<String, List<Double>>();
        List<String> expHeaders = new ArrayList<String>();

        try {
            CSVContents csv = new CSVContents(job.experimentalData);
            csv.abbreviateContents = 0;
            csv.readAll(expData);
            expHeaders = csv.getHeaders();
        } catch (Exception e) {
            Log.error("Unable to read experimental data");
        }

        if (!expData.isEmpty() && !expHeaders.isEmpty()) {
            List<Double> expTimeData = new ArrayList<Double>();
            expTimeData = expData.get("Time(s)");

            for (String h : expHeaders) //Will assume all headers from exp file will be on same Y axis vs time
            {
                if (h.equalsIgnoreCase("Time(s)"))
                    continue;

                expDataSet.addSeries(plotTool.createXYSeries("Experimental " + h, expTimeData, expData.get(h)));
            }
        }
    }

    //set labels
    String XAxisLabel = "Time(s)";
    String YAxisLabel = job.headers.get(0);

    JFreeChart chart = ChartFactory.createXYLineChart(
            job.titleOverride != null && job.titleOverride.equalsIgnoreCase("None") ? "" : title, // chart title
            XAxisLabel, // x axis label
            YAxisLabel, // y axis label
            dataSet, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    Log.info("Creating Graph " + title);
    XYPlot plot = (XYPlot) chart.getPlot();

    if (!job.logAxis) {
        // Determine Y range
        double resMax0 = maxY;
        double resMin0 = minY;
        if (Double.isNaN(resMax0) || Double.isNaN(resMin0))
            plot.getDomainAxis().setLabel("Range is NaN");
        if (DoubleUtils.isZero(resMin0))
            resMin0 = -0.000001;
        if (DoubleUtils.isZero(resMax0))
            resMax0 = 0.000001;
        if (job.forceZeroYAxisBound && resMin0 >= 0)
            resMin0 = -.000001;
        if (job.forceZeroYAxisBound && resMax0 <= 0)
            resMax0 = .000001;
        rangeLength = resMax0 - resMin0;
        ValueAxis yAxis = plot.getRangeAxis();
        if (rangeLength != 0)
            yAxis.setRange(resMin0 - 0.15 * rangeLength, resMax0 + 0.15 * rangeLength);//15% buffer so we can see top and bottom clearly           

        //Add another Y axis to the right side for easier reading
        ValueAxis rightYAxis = new NumberAxis();
        rightYAxis.setRange(yAxis.getRange());
        rightYAxis.setLabel("");

        //Override the bounds if desired
        try {
            if (job.Y1LowerBound != null) {
                yAxis.setLowerBound(job.Y1LowerBound);
                rightYAxis.setLowerBound(job.Y1LowerBound);
            }
            if (job.Y1UpperBound != null) {
                yAxis.setUpperBound(job.Y1UpperBound);
                rightYAxis.setUpperBound(job.Y1UpperBound);
            }
        } catch (Exception e) {
            Log.error(
                    "Couldn't set Y bounds. You probably tried to set a bound on an axis that doesn't exist.");
        }
        plot.setRangeAxis(0, yAxis);
        plot.setRangeAxis(1, rightYAxis);

    } else {
        double resMin = minY;
        double resMax = maxY;
        if (resMin <= 0.0)
            resMin = .00001;
        LogarithmicAxis yAxis = new LogarithmicAxis("Log(" + YAxisLabel + ")");
        LogarithmicAxis rightYAxis = new LogarithmicAxis("");
        yAxis.setLowerBound(resMin);
        rightYAxis.setLowerBound(resMin);
        yAxis.setUpperBound(resMax);
        rightYAxis.setUpperBound(resMax);

        //Override the bounds if desired
        try {
            if (job.Y1LowerBound != null) {
                yAxis.setLowerBound(job.Y1LowerBound);
                rightYAxis.setLowerBound(job.Y1LowerBound);
            }
            if (job.Y1UpperBound != null) {
                yAxis.setUpperBound(job.Y1UpperBound);
                rightYAxis.setUpperBound(job.Y1UpperBound);
            }
        } catch (Exception e) {
            Log.error(
                    "Couldn't set Y bounds. You probably tried to set a bound on an axis that doesn't exist.");
        }
        plot.setRangeAxis(0, yAxis);
        plot.setRangeAxis(1, rightYAxis);
    }

    //Override X bounds if desired
    try {
        if (job.X1LowerBound != null)
            plot.getDomainAxis(0).setLowerBound(job.X1LowerBound);
        if (job.X1UpperBound != null)
            plot.getDomainAxis(0).setUpperBound(job.X1UpperBound);
    } catch (Exception e) {
        Log.error("Couldn't set X bounds. You probably tried to set a bound on an axis that doesn't exist.");
    }

    //Override labels if desired
    if (job.X1Label != null && !plot.getDomainAxis(0).getLabel().contains("NaN"))
        plot.getDomainAxis(0).setLabel(job.X1Label.equalsIgnoreCase("None") ? "" : job.X1Label);
    if (job.Y1Label != null)
        plot.getRangeAxis(0).setLabel(job.Y1Label.equalsIgnoreCase("None") ? "" : job.Y1Label);

    //If we have experimental data, set up the renderer for it and add to plot
    if (expDataSet.getSeriesCount() != 0) {
        XYItemRenderer renderer1 = new XYLineAndShapeRenderer(false, true); // Shapes only
        renderer1.setSeriesShape(0, ShapeUtilities.createDiamond(8));
        plot.setDataset(1, expDataSet);
        plot.setRenderer(1, renderer1);
        plot.mapDatasetToDomainAxis(1, 0);
        plot.mapDatasetToRangeAxis(1, 0);
    }

    formatAEPlot(job, chart);
    plot.setDomainGridlinesVisible(job.showGridLines);
    plot.setRangeGridlinesVisible(job.showGridLines);

    //Changing line widths and colors
    XYItemRenderer r = plot.getRenderer();
    BasicStroke wideLine = new BasicStroke(2.0f);
    Color[] AEcolors = { Color.red, Color.green, Color.black, Color.magenta, Color.orange };
    Color[] dataColors = { Color.blue, Color.cyan, Color.gray, Color.black, Color.red };
    for (int i = 0, cIndex = 0; i < dataSet.getSeriesCount(); i++, cIndex++) {
        r.setSeriesStroke(i, wideLine);
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
        renderer.setBaseShapesVisible(false);
        if (cIndex > 4)
            cIndex = 0;
        if (i < job.headers.size()) //Our actual data
        {
            renderer.setSeriesFillPaint(i, dataColors[cIndex]);
            renderer.setSeriesPaint(i, dataColors[cIndex]);
        } else //actions and events in procession of other colors
        {
            renderer.setSeriesFillPaint(i, AEcolors[cIndex]);
            renderer.setSeriesPaint(i, AEcolors[cIndex]);
        }
    }
    //Special color and format changes for compare plots
    if (job.isComparePlot) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();

        for (int i = 0; i < dataSet.getSeriesCount(); i++) {
            if (dataSet.getSeries(i).getKey().toString().equalsIgnoreCase("Expected")) {
                renderer.setSeriesStroke(//makes a dashed line
                        i, //argument below float[]{I,K} -> alternates between solid and opaque (solid for I, opaque for K)
                        new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                                new float[] { 15.0f, 30.0f }, 0.0f));
                renderer.setDrawSeriesLineAsPath(true);
                renderer.setUseFillPaint(true);
                renderer.setBaseShapesVisible(false);
                renderer.setSeriesFillPaint(i, Color.black);
                renderer.setSeriesPaint(i, Color.black);
            }
            if (dataSet.getSeries(i).getKey().toString().equalsIgnoreCase("Computed")) {
                renderer.setSeriesFillPaint(i, Color.red);
                renderer.setSeriesPaint(i, Color.red);
            }
            if (dataSet.getSeries(i).getKey().toString().startsWith("ACTION")) {
                renderer.setSeriesFillPaint(i, Color.green);
                renderer.setSeriesPaint(i, Color.green);
            }
            if (dataSet.getSeries(i).getKey().toString().startsWith("EVENT")) {
                renderer.setSeriesFillPaint(i, Color.blue);
                renderer.setSeriesPaint(i, Color.blue);
            }
        }
    }

    //Split the auto-generated legend into two legends, one for data and one for actions and events
    LegendItemCollection originalLegendCollection = plot.getLegendItems();
    final LegendItemCollection dataLegendCollection = new LegendItemCollection();
    int i;
    for (i = 0; i < job.headers.size() && i < originalLegendCollection.getItemCount(); i++) {
        if (originalLegendCollection.get(i).getLabel().startsWith("ACTION")
                || originalLegendCollection.get(i).getLabel().startsWith("EVENT"))
            break;
        dataLegendCollection.add(originalLegendCollection.get(i));
    }
    final LegendItemCollection remainingLegendCollection = new LegendItemCollection();
    for (; i < originalLegendCollection.getItemCount(); i++) {
        remainingLegendCollection.add(originalLegendCollection.get(i));
    }
    chart.removeLegend();
    LegendItemSource source = new LegendItemSource() {
        LegendItemCollection lic = new LegendItemCollection();
        {
            lic.addAll(dataLegendCollection);
        }

        public LegendItemCollection getLegendItems() {
            return lic;
        }
    };
    LegendTitle dataLegend = new LegendTitle(source);
    dataLegend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    dataLegend.setBorder(2, 2, 2, 2);
    dataLegend.setBackgroundPaint(Color.white);
    dataLegend.setPosition(RectangleEdge.TOP);
    dataLegend.setItemFont(new Font("SansSerif", Font.PLAIN, 22));
    chart.addLegend(dataLegend);

    source = new LegendItemSource() {
        LegendItemCollection lic = new LegendItemCollection();
        {
            lic.addAll(remainingLegendCollection);
        }

        public LegendItemCollection getLegendItems() {
            return lic;
        }
    };
    LegendTitle actionEventsLegend = new LegendTitle(source);
    actionEventsLegend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    actionEventsLegend.setBorder(2, 2, 2, 2);
    actionEventsLegend.setBackgroundPaint(Color.white);
    actionEventsLegend.setPosition(RectangleEdge.BOTTOM);
    actionEventsLegend.setItemFont(new Font("SansSerif", Font.PLAIN, 22));
    if (!job.hideAELegend && !job.removeAllLegends)
        chart.addLegend(actionEventsLegend);

    if (job.removeAllLegends)
        chart.removeLegend();

    int verticalPixels = 800 + 170 * (allActionsAndEvents.size() / 5);

    //This is a little hacky, but if we want only the legend, just extend Plot() and remove the draw functionality so it makes a blank plot
    class legendPlot extends Plot {
        public void draw(Graphics2D arg0, Rectangle2D arg1, Point2D arg2, PlotState arg3,
                PlotRenderingInfo arg4) {

        }

        public String getPlotType() {
            return null;
        }
    }
    //Then add the legend to that and throw away the original plot
    if (job.legendOnly) {
        chart = new JFreeChart("", null, new legendPlot(), false);
        chart.addLegend(actionEventsLegend);
    }

    try {
        FileUtils.createDirectory(job.outputDir);
        String filename = job.outputFilename == null
                ? job.outputDir + "/" + plotTool.MakeFileName(title) + ".jpg"
                : job.outputDir + "/" + job.outputFilename;
        if (!filename.endsWith(".jpg"))
            filename = filename + ".jpg";
        File JPGFile = new File(filename);
        if (job.imageHeight != null && job.imageWidth != null)
            ChartUtilities.saveChartAsJPEG(JPGFile, chart, job.imageWidth, job.imageHeight);
        else if (!job.hideAELegend && !job.removeAllLegends)
            ChartUtilities.saveChartAsJPEG(JPGFile, chart, 1600, verticalPixels);
        else
            ChartUtilities.saveChartAsJPEG(JPGFile, chart, 1600, 800);
    } catch (IOException e) {
        Log.error(e.getMessage());
    }
}

From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputScatter.java

@Override
public void resetAxes(final IScope scope) {
    NumberAxis domainAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis();
    NumberAxis rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis();
    NumberAxis range2Axis = rangeAxis;//from w  w  w.j a  v  a2s  . c o  m
    boolean secondaxis = false;
    if (getUseSecondYAxis(scope)) {
        secondaxis = true;
        range2Axis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(1);
        if (range2Axis == null) {
            NumberAxis secondAxis = new NumberAxis("");
            ((XYPlot) this.chart.getPlot()).setRangeAxis(1, secondAxis);
            range2Axis = secondAxis;
            range2Axis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(1);
            range2Axis = formatYAxis(scope, range2Axis);

            ((XYPlot) this.chart.getPlot()).setRangeAxis(1, range2Axis);
        }
    }

    if (getX_LogScale(scope)) {
        LogarithmicAxis logAxis = new LogarithmicAxis(domainAxis.getLabel());
        logAxis.setAllowNegativesFlag(true);
        ((XYPlot) this.chart.getPlot()).setDomainAxis(logAxis);
        domainAxis = logAxis;
    }
    if (getY_LogScale(scope)) {
        LogarithmicAxis logAxis = new LogarithmicAxis(rangeAxis.getLabel());
        logAxis.setAllowNegativesFlag(true);
        logAxis = (LogarithmicAxis) formatYAxis(scope, logAxis);
        ((XYPlot) this.chart.getPlot()).setRangeAxis(logAxis);
        rangeAxis = logAxis;
    }
    if (secondaxis) {
        if (getY2_LogScale(scope)) {
            LogarithmicAxis logAxis = new LogarithmicAxis(range2Axis.getLabel());
            logAxis.setAllowNegativesFlag(true);
            logAxis = (LogarithmicAxis) formatYAxis(scope, logAxis);
            ((XYPlot) this.chart.getPlot()).setRangeAxis(1, logAxis);
            range2Axis = logAxis;
        }

    }

    if (!getUseXRangeInterval(scope) && !getUseXRangeMinMax(scope)) {
        domainAxis.setAutoRange(true);
    }

    if (this.getUseXRangeInterval(scope)) {
        domainAxis.setFixedAutoRange(getXRangeInterval(scope));
        domainAxis.setAutoRangeMinimumSize(getXRangeInterval(scope));
        domainAxis.setAutoRange(true);

    }
    if (this.getUseXRangeMinMax(scope)) {
        domainAxis.setRange(getXRangeMin(scope), getXRangeMax(scope));

    }
    if (this.getXTickLineVisible(scope)) {
        ((XYPlot) this.chart.getPlot()).setDomainGridlinePaint(this.tickColor);
        if (getXTickUnit(scope) > 0) {
            domainAxis.setTickUnit(new NumberTickUnit(getXTickUnit(scope)));
            ((XYPlot) this.chart.getPlot()).setDomainGridlinesVisible(true);
        } else
            ((XYPlot) this.chart.getPlot())
                    .setDomainGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue());

    } else {
        ((XYPlot) this.chart.getPlot()).setDomainGridlinesVisible(false);

    }

    if (!getUseYRangeInterval(scope) && !getUseYRangeMinMax(scope)) {
        rangeAxis.setAutoRange(true);
    }

    if (this.getUseYRangeInterval(scope)) {
        rangeAxis.setFixedAutoRange(getYRangeInterval(scope));
        rangeAxis.setAutoRangeMinimumSize(getYRangeInterval(scope));
        rangeAxis.setAutoRange(true);
    }
    if (this.getUseYRangeMinMax(scope)) {
        rangeAxis.setRange(getYRangeMin(scope), getYRangeMax(scope));

    }
    if (this.getYTickLineVisible(scope)) {
        ((XYPlot) this.chart.getPlot()).setRangeGridlinePaint(this.tickColor);
        if (getYTickUnit(scope) > 0) {
            rangeAxis.setTickUnit(new NumberTickUnit(getYTickUnit(scope)));
            ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(true);
        } else
            ((XYPlot) this.chart.getPlot())
                    .setRangeGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue());

    } else {
        ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(false);

    }

    if (secondaxis) {
        if (!getUseY2RangeInterval(scope) && !getUseY2RangeMinMax(scope)) {
            range2Axis.setAutoRange(true);
        }

        if (this.getUseY2RangeInterval(scope)) {
            range2Axis.setFixedAutoRange(getY2RangeInterval(scope));
            range2Axis.setAutoRangeMinimumSize(getY2RangeInterval(scope));
            range2Axis.setAutoRange(true);
        }
        if (this.getUseY2RangeMinMax(scope)) {
            range2Axis.setRange(getY2RangeMin(scope), getY2RangeMax(scope));

        }
        if (this.getYTickLineVisible(scope)) {
            ((XYPlot) this.chart.getPlot()).setRangeGridlinePaint(this.tickColor);
            if (getY2TickUnit(scope) > 0) {
                range2Axis.setTickUnit(new NumberTickUnit(getY2TickUnit(scope)));
                ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(true);
            } else
                ((XYPlot) this.chart.getPlot())
                        .setRangeGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue());

        } else {
            ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(false);

        }

    }

    if (getXLabel(scope) != null && !getXLabel(scope).isEmpty()) {
        domainAxis.setLabel(getXLabel(scope));
    }
    if (getYLabel(scope) != null && !getYLabel(scope).isEmpty()) {
        rangeAxis.setLabel(getYLabel(scope));
    }
    if (secondaxis) {
        if (getY2Label(scope) != null && !getY2Label(scope).isEmpty()) {
            range2Axis.setLabel(getY2Label(scope));
        }

    }
    if (this.series_label_position.equals("none")) {
        (this.chart).getLegend().setVisible(false);
    }
    if (!this.getXTickValueVisible(scope)) {
        domainAxis.setTickMarksVisible(false);
        domainAxis.setTickLabelsVisible(false);

    }

}

From source file:asl.util.PlotMaker.java

public void plotSpecAmp2(double freq[], double[] amp1, double[] phase1, double[] amp2, double[] phase2,
        String plotTitle, String pngName) {

    /**// w  w  w .j  ava  2  s.  c  om
            final String plotTitle = String.format("%04d%03d.%s.%s %s", date.get(Calendar.YEAR), date.get(Calendar.DAY_OF_YEAR)
                                        ,station, channel, plotString);
            final String pngName   = String.format("%s/%04d%03d.%s.%s.%s.png", outputDir, date.get(Calendar.YEAR), date.get(Calendar.DAY_OF_YEAR)
                                        ,station, channel, plotString);
    **/
    File outputFile = new File(pngName);

    // Check that we will be able to output the file without problems and if not --> return
    if (!checkFileOut(outputFile)) {
        System.out.format("== plotSpecAmp: request to output plot=[%s] but we are unable to create it "
                + " --> skip plot\n", pngName);
        return;
    }
    // Plot x-axis (frequency) range
    final double XMIN = .00009;
    final double XMAX = freq[freq.length - 1];

    System.out.format("== plotSpecAmp2: nfreq=%d npts=%d pngName=%s\n", freq.length, amp2.length, pngName);

    final XYSeries series1 = new XYSeries("Amp_PZ");
    final XYSeries series1b = new XYSeries("Amp_Cal");

    final XYSeries series2 = new XYSeries("Phase_PZ");
    final XYSeries series2b = new XYSeries("Phase_Cal");

    double maxdB = 0.;
    for (int k = 0; k < freq.length; k++) {
        double dB = amp1[k];
        //double dB = 20. * Math.log10( amp1[k] );
        //series1.add( freq[k], dB );
        //series1.add( freq[k], 20. * Math.log10( amp1[k] ) );
        //series1b.add(freq[k], 20. * Math.log10( amp2[k] ));
        series1.add(freq[k], amp1[k]);
        series1b.add(freq[k], amp2[k]);
        series2.add(freq[k], phase1[k]);
        series2b.add(freq[k], phase2[k]);
        if (dB > maxdB) {
            maxdB = dB;
        }
    }

    //final XYItemRenderer renderer = new StandardXYItemRenderer();
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    Rectangle rectangle = new Rectangle(3, 3);
    renderer.setSeriesShape(0, rectangle);
    //renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesLinesVisible(0, true);

    renderer.setSeriesShape(1, rectangle);
    renderer.setSeriesShapesVisible(1, true);
    renderer.setSeriesLinesVisible(1, false);

    Paint[] paints = new Paint[] { Color.red, Color.blue };
    renderer.setSeriesPaint(0, paints[0]);
    //renderer.setSeriesPaint(1, paints[1]);

    final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesPaint(0, paints[1]);
    renderer2.setSeriesShapesVisible(0, false);
    renderer2.setSeriesLinesVisible(0, true);

    // Stroke is part of Java Swing ...
    //renderer2.setBaseStroke( new Stroke( ... ) );

    double ymax;
    if (maxdB < 10) {
        ymax = 10.;
    } else {
        ymax = maxdB + 2;
        ;
    }

    final NumberAxis verticalAxis = new NumberAxis("Spec Amp (dB)");
    verticalAxis.setRange(new Range(-40, ymax));
    verticalAxis.setTickUnit(new NumberTickUnit(5));

    //final LogarithmicAxis verticalAxis = new LogarithmicAxis("Amplitude Response");
    //verticalAxis.setRange( new Range(0.01 , 10) );

    final LogarithmicAxis horizontalAxis = new LogarithmicAxis("Frequency (Hz)");
    //horizontalAxis.setRange( new Range(0.0001 , 100.5) );
    //horizontalAxis.setRange( new Range(0.00009 , 110) );
    horizontalAxis.setRange(new Range(XMIN, XMAX));

    final XYSeriesCollection seriesCollection = new XYSeriesCollection();
    seriesCollection.addSeries(series1);
    seriesCollection.addSeries(series1b);

    final XYPlot xyplot = new XYPlot((XYDataset) seriesCollection, null, verticalAxis, renderer);
    //final XYPlot xyplot = new XYPlot((XYDataset)seriesCollection, horizontalAxis, verticalAxis, renderer);

    xyplot.setDomainGridlinesVisible(true);
    xyplot.setRangeGridlinesVisible(true);
    xyplot.setRangeGridlinePaint(Color.black);
    xyplot.setDomainGridlinePaint(Color.black);

    final NumberAxis phaseAxis = new NumberAxis("Phase (Deg)");
    phaseAxis.setRange(new Range(-180, 180));
    phaseAxis.setTickUnit(new NumberTickUnit(30));
    final XYSeriesCollection seriesCollection2 = new XYSeriesCollection();
    seriesCollection2.addSeries(series2);
    seriesCollection2.addSeries(series2b);
    final XYPlot xyplot2 = new XYPlot((XYDataset) seriesCollection2, null, phaseAxis, renderer2);

    //CombinedXYPlot combinedPlot = new CombinedXYPlot( horizontalAxis, CombinedXYPlot.VERTICAL );
    CombinedDomainXYPlot combinedPlot = new CombinedDomainXYPlot(horizontalAxis);
    combinedPlot.add(xyplot, 1);
    combinedPlot.add(xyplot2, 1);
    combinedPlot.setGap(15.);

    //final JFreeChart chart = new JFreeChart(xyplot);
    final JFreeChart chart = new JFreeChart(combinedPlot);
    chart.setTitle(new TextTitle(plotTitle));

    try {
        ChartUtilities.saveChartAsPNG(outputFile, chart, 1000, 800);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart.");

    }
}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates and returns a sample time series chart.
 *
 * @return a sample time series chart./*  w ww .  j  ava2  s  .c  o m*/
 */
public JFreeChart createTimeSeries2Chart() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("timeseries.sample2.title");
    final String subtitleStr = this.resources.getString("timeseries.sample2.subtitle");
    final String domain = this.resources.getString("timeseries.sample2.domain");
    final String range = this.resources.getString("timeseries.sample2.range");
    final XYDataset data = DemoDatasetFactory.createTimeSeriesCollection4();
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, domain, range, data, true, true, false);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    final XYPlot plot = chart.getXYPlot();
    final LogarithmicAxis rangeAxis = new LogarithmicAxis(range);
    plot.setRangeAxis(rangeAxis);
    return chart;

}

From source file:jhplot.HChart.java

/**
 * Sets true or false to plot on a log scale.
 * //  w  w w  . j  a v a2 s .c  o m
 * @param axis
 *            defines to which axis this function applies, generally
 *            something like <a href="#X_AXIS">X_AXIS</a> or <a
 *            href="#Y_AXIS">Y_AXIS</a>.
 * @param b
 *            toggle, true if the scaling is logarithmic
 */
public void setLogScale(int axis, boolean b) {

    isLog[axis] = b;

    if (isLog[0] == false) {
        xAxis[N1][N2] = new NumberAxis(titleX[N1][N2]);
    }
    if (isLog[0] == true) {
        xAxis[N1][N2] = new LogarithmicAxis(titleX[N1][N2]);
    }

    if (isLog[1] == false) {
        yAxis[N1][N2] = new NumberAxis(titleY[N1][N2]);
    }
    if (isLog[1] == true) {
        yAxis[N1][N2] = new LogarithmicAxis(titleY[N1][N2]);
    }

}

From source file:hudson.plugins.plot.Plot.java

/**
 * Generates the plot and stores it in the plot instance variable.
 *
 * @param forceGenerate//w w  w. j av a 2 s . co m
 *            if true, force the plot to be re-generated even if the on-disk
 *            data hasn't changed
 */
private void generatePlot(boolean forceGenerate) {
    class Label implements Comparable<Label> {
        final private Integer buildNum;
        final private String buildDate;
        final private String text;

        public Label(String buildNum, String buildTime, String text) {
            this.buildNum = Integer.parseInt(buildNum);
            synchronized (DATE_FORMAT) {
                this.buildDate = DATE_FORMAT.format(new Date(Long.parseLong(buildTime)));
            }
            this.text = text;
        }

        public Label(String buildNum, String buildTime) {
            this(buildNum, buildTime, null);
        }

        public int compareTo(Label that) {
            return this.buildNum - that.buildNum;
        }

        @Override
        public boolean equals(Object o) {
            return o instanceof Label && ((Label) o).buildNum.equals(buildNum);
        }

        @Override
        public int hashCode() {
            return buildNum.hashCode();
        }

        public String numDateString() {
            return "#" + buildNum + " (" + buildDate + ")";
        }

        @Override
        public String toString() {
            return text != null ? text : numDateString();
        }
    }
    // LOGGER.info("Determining if we should generate plot " +
    // getCsvFileName());
    File csvFile = new File(project.getRootDir(), getCsvFileName());
    if (csvFile.lastModified() == csvLastModification && plot != null && !forceGenerate) {
        // data hasn't changed so don't regenerate the plot
        return;
    }
    if (rawPlotData == null || csvFile.lastModified() > csvLastModification) {
        // data has changed or has not been loaded so load it now
        loadPlotData();
    }
    // LOGGER.info("Generating plot " + getCsvFileName());
    csvLastModification = csvFile.lastModified();
    PlotCategoryDataset dataset = new PlotCategoryDataset();
    for (String[] record : rawPlotData) {
        // record: series y-value, series label, build number, build date,
        // url
        int buildNum;
        try {
            buildNum = Integer.valueOf(record[2]);
            if (!reportBuild(buildNum) || buildNum > getRightBuildNum()) {
                continue; // skip this record
            }
        } catch (NumberFormatException nfe) {
            LOGGER.log(Level.SEVERE, "Exception converting to integer", nfe);
            continue; // skip this record all together
        }
        Number value = null;
        try {
            value = Integer.valueOf(record[0]);
        } catch (NumberFormatException nfe) {
            try {
                value = Double.valueOf(record[0]);
            } catch (NumberFormatException nfe2) {
                LOGGER.log(Level.SEVERE, "Exception converting to number", nfe2);
                continue; // skip this record all together
            }
        }
        String series = record[1];
        Label xlabel = getUrlUseDescr() ? new Label(record[2], record[3], descriptionForBuild(buildNum))
                : new Label(record[2], record[3]);
        String url = null;
        if (record.length >= 5)
            url = record[4];
        dataset.setValue(value, url, series, xlabel);
    }

    String urlNumBuilds = getURLNumBuilds();
    int numBuilds;
    if (StringUtils.isBlank(urlNumBuilds)) {
        numBuilds = Integer.MAX_VALUE;
    } else {
        try {
            numBuilds = Integer.parseInt(urlNumBuilds);
        } catch (NumberFormatException nfe) {
            LOGGER.log(Level.SEVERE, "Exception converting to integer", nfe);
            numBuilds = Integer.MAX_VALUE;
        }
    }

    dataset.clipDataset(numBuilds);
    plot = createChart(dataset);
    CategoryPlot categoryPlot = (CategoryPlot) plot.getPlot();
    categoryPlot.setDomainGridlinePaint(Color.black);
    categoryPlot.setRangeGridlinePaint(Color.black);
    categoryPlot.setDrawingSupplier(Plot.supplier);
    CategoryAxis domainAxis = new ShiftedCategoryAxis(Messages.Plot_Build());
    categoryPlot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.03);
    domainAxis.setCategoryMargin(0.0);
    for (Object category : dataset.getColumnKeys()) {
        Label label = (Label) category;
        if (label.text != null) {
            domainAxis.addCategoryLabelToolTip(label, label.numDateString());
        } else {
            domainAxis.addCategoryLabelToolTip(label, descriptionForBuild(label.buildNum));
        }
    }
    // Replace the range axis by a logarithmic axis if the option is
    // selected
    if (isLogarithmic()) {
        LogarithmicAxis logAxis = new LogarithmicAxis(getYaxis());
        logAxis.setExpTickLabelsFlag(true);
        categoryPlot.setRangeAxis(logAxis);
    }

    // optionally exclude zero as default y-axis value
    ValueAxis rangeAxis = categoryPlot.getRangeAxis();
    if ((rangeAxis != null) && (rangeAxis instanceof NumberAxis)) {
        if (hasYaxisMinimum()) {
            ((NumberAxis) rangeAxis).setLowerBound(getYaxisMinimum());
        }
        if (hasYaxisMaximum()) {
            ((NumberAxis) rangeAxis).setUpperBound(getYaxisMaximum());
        }
        ((NumberAxis) rangeAxis).setAutoRangeIncludesZero(!getExclZero());
    }

    AbstractCategoryItemRenderer renderer = (AbstractCategoryItemRenderer) categoryPlot.getRenderer();
    int numColors = dataset.getRowCount();
    for (int i = 0; i < numColors; i++) {
        renderer.setSeriesPaint(i, new Color(Color.HSBtoRGB((1f / numColors) * i, 1f, 1f)));
    }
    renderer.setBaseStroke(new BasicStroke(2.0f));
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator(Messages.Plot_Build() + " {1}: {2}",
            NumberFormat.getInstance()));
    renderer.setBaseItemURLGenerator(new PointURLGenerator());
    if (renderer instanceof LineAndShapeRenderer) {
        String s = getUrlStyle();
        LineAndShapeRenderer lasRenderer = (LineAndShapeRenderer) renderer;
        if ("lineSimple".equalsIgnoreCase(s)) {
            lasRenderer.setShapesVisible(false); // TODO: deprecated, may be unnecessary
        } else {
            lasRenderer.setShapesVisible(true); // TODO: deprecated, may be unnecessary
        }
    }
}

From source file:asl.util.PlotMaker.java

public void plotSpecAmp(double freq[], double[] amp, double[] phase, String plotString) {

    // plotTitle = "2012074.IU_ANMO.00-BHZ " + plotString
    final String plotTitle = String.format("%04d%03d.%s.%s %s", date.get(Calendar.YEAR),
            date.get(Calendar.DAY_OF_YEAR), station, channel, plotString);
    // plot filename = "2012074.IU_ANMO.00-BHZ" + plotString + ".png"
    final String pngName = String.format("%s/%04d%03d.%s.%s.%s.png", outputDir, date.get(Calendar.YEAR),
            date.get(Calendar.DAY_OF_YEAR), station, channel, plotString);

    File outputFile = new File(pngName);

    // Check that we will be able to output the file without problems and if not --> return
    if (!checkFileOut(outputFile)) {
        System.out.format("== plotSpecAmp: request to output plot=[%s] but we are unable to create it "
                + " --> skip plot\n", pngName);
        return;/*from   ww  w.java2  s  . co  m*/
    }

    final XYSeries series1 = new XYSeries("Amplitude");
    final XYSeries series2 = new XYSeries("Phase");

    double maxdB = 0.;
    for (int k = 0; k < freq.length; k++) {
        double dB = 20. * Math.log10(amp[k]);
        series1.add(freq[k], dB);
        series2.add(freq[k], phase[k]);
        if (dB > maxdB) {
            maxdB = dB;
        }
    }

    //final XYItemRenderer renderer = new StandardXYItemRenderer();
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    Rectangle rectangle = new Rectangle(3, 3);
    renderer.setSeriesShape(0, rectangle);
    //renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesLinesVisible(0, true);

    renderer.setSeriesShape(1, rectangle);
    renderer.setSeriesShapesVisible(1, true);
    renderer.setSeriesLinesVisible(1, false);

    Paint[] paints = new Paint[] { Color.red, Color.blue };
    renderer.setSeriesPaint(0, paints[0]);
    //renderer.setSeriesPaint(1, paints[1]);

    final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesPaint(0, paints[1]);
    renderer2.setSeriesShapesVisible(0, false);
    renderer2.setSeriesLinesVisible(0, true);

    // Stroke is part of Java Swing ...
    //renderer2.setBaseStroke( new Stroke( ... ) );

    double ymax;
    if (maxdB < 10) {
        ymax = 10.;
    } else {
        ymax = maxdB + 2;
        ;
    }

    final NumberAxis verticalAxis = new NumberAxis("Spec Amp (dB)");
    verticalAxis.setRange(new Range(-40, ymax));
    verticalAxis.setTickUnit(new NumberTickUnit(5));

    //final LogarithmicAxis verticalAxis = new LogarithmicAxis("Amplitude Response");
    //verticalAxis.setRange( new Range(0.01 , 10) );

    final LogarithmicAxis horizontalAxis = new LogarithmicAxis("Frequency (Hz)");
    //horizontalAxis.setRange( new Range(0.0001 , 100.5) );
    horizontalAxis.setRange(new Range(0.00009, 110));

    final XYSeriesCollection seriesCollection = new XYSeriesCollection();
    seriesCollection.addSeries(series1);

    final XYPlot xyplot = new XYPlot((XYDataset) seriesCollection, null, verticalAxis, renderer);
    //final XYPlot xyplot = new XYPlot((XYDataset)seriesCollection, horizontalAxis, verticalAxis, renderer);

    xyplot.setDomainGridlinesVisible(true);
    xyplot.setRangeGridlinesVisible(true);
    xyplot.setRangeGridlinePaint(Color.black);
    xyplot.setDomainGridlinePaint(Color.black);

    final NumberAxis phaseAxis = new NumberAxis("Phase (Deg)");
    phaseAxis.setRange(new Range(-180, 180));
    phaseAxis.setTickUnit(new NumberTickUnit(30));
    final XYSeriesCollection seriesCollection2 = new XYSeriesCollection();
    seriesCollection2.addSeries(series2);
    final XYPlot xyplot2 = new XYPlot((XYDataset) seriesCollection2, null, phaseAxis, renderer2);

    //CombinedXYPlot combinedPlot = new CombinedXYPlot( horizontalAxis, CombinedXYPlot.VERTICAL );
    CombinedDomainXYPlot combinedPlot = new CombinedDomainXYPlot(horizontalAxis);
    combinedPlot.add(xyplot, 1);
    combinedPlot.add(xyplot2, 1);
    combinedPlot.setGap(15.);

    //final JFreeChart chart = new JFreeChart(xyplot);
    final JFreeChart chart = new JFreeChart(combinedPlot);
    chart.setTitle(new TextTitle(plotTitle));

    // Here we need to see if test dir exists and create it if necessary ...
    try {
        //ChartUtilities.saveChartAsJPEG(new File("chart.jpg"), chart, 500, 300);
        //ChartUtilities.saveChartAsPNG(outputFile, chart, 500, 300);
        ChartUtilities.saveChartAsPNG(outputFile, chart, 1000, 800);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart.");

    }
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.CategoricalChartExpression.java

protected void configureLogarithmicAxis(final CategoryPlot plot) {
    if (isLogarithmicAxis()) {
        final LogarithmicAxis logarithmicAxis;
        if (isHumanReadableLogarithmicFormat()) {
            plot.getRenderer().setBaseItemLabelGenerator(new LogCategoryItemLabelGenerator());
            logarithmicAxis = new ScalingLogarithmicAxis(getValueAxisLabel());
            logarithmicAxis.setStrictValuesFlag(false);
        } else {//  w  ww.  j a va 2s .c om
            logarithmicAxis = new LogarithmicAxis(getValueAxisLabel());
            logarithmicAxis.setStrictValuesFlag(false);
        }

        plot.setRangeAxis(logarithmicAxis);
    }
}