Example usage for org.jfree.chart.axis LogAxis setMinorTickCount

List of usage examples for org.jfree.chart.axis LogAxis setMinorTickCount

Introduction

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

Prototype

public void setMinorTickCount(int count) 

Source Link

Document

Sets the number of minor tick marks to display, and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:org.gwaspi.reports.PlinkReportLoaderCombined.java

private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome,
        XYSeriesCollection tempChrData, boolean showlables) {
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    renderer.setSeriesVisibleInLegend(0, showlables);
    renderer.setSeriesVisibleInLegend(1, showlables);
    //renderer.setBaseShape(new Ellipse2D.Float(0, 0, 2,2), false);

    if (combinedPlot.getSubplots().isEmpty()) {
        LogAxis rangeAxis = new LogAxis("P value");
        rangeAxis.setBase(10);/*from  w w  w.ja v a  2  s . c  o  m*/
        rangeAxis.setInverted(true);
        rangeAxis.setNumberFormatOverride(GenericReportGenerator.FORMAT_P_VALUE);

        rangeAxis.setTickMarkOutsideLength(2.0f);
        rangeAxis.setMinorTickCount(2);
        rangeAxis.setMinorTickMarksVisible(true);
        rangeAxis.setAxisLineVisible(true);
        rangeAxis.setAutoRangeMinimumSize(0.0000005);
        rangeAxis.setLowerBound(1d);
        //rangeAxis.setAutoRangeIncludesZero(false);

        combinedPlot.setRangeAxis(0, rangeAxis);
    }

    JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", tempChrData,
            PlotOrientation.VERTICAL, true, false, false);

    XYPlot subplot = (XYPlot) subchart.getPlot();
    subplot.setRenderer(renderer);
    subplot.setBackgroundPaint(null);

    final Marker thresholdLine = new ValueMarker(0.0000005);
    thresholdLine.setPaint(Color.red);
    if (showlables) {
        thresholdLine.setLabel("P = 510??");
    }
    thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    subplot.addRangeMarker(thresholdLine);

    NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis();
    chrAxis.setAxisLineVisible(false);
    chrAxis.setTickLabelsVisible(false);
    chrAxis.setTickMarksVisible(false);
    chrAxis.setAutoRangeIncludesZero(false);
    //combinedPlot.setGap(0);
    combinedPlot.add(subplot, 1);
}

From source file:org.gwaspi.reports.GenericReportGenerator.java

private static void appendToCombinedRangeManhattanPlot(CombinedRangeXYPlot combinedPlot, String chromosome,
        XYSeriesCollection currChrSC, boolean showlables, double threshold, Color background,
        Color backgroundAlternative, Color main) {

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);

    // Set dot shape of the currently appended Series
    renderer.setSeriesPaint(currChrSC.getSeriesCount() - 1, main);
    renderer.setSeriesVisibleInLegend(currChrSC.getSeriesCount() - 1, showlables);
    renderer.setSeriesShape(currChrSC.getSeriesCount() - 1, new Rectangle2D.Double(-1.0, -1.0, 2.0, 2.0));

    // Set range axis
    if (combinedPlot.getSubplots().isEmpty()) {
        LogAxis rangeAxis = new LogAxis("P value");
        rangeAxis.setBase(10);/*from w  w w  . ja v  a2  s. c  om*/
        rangeAxis.setInverted(true);
        rangeAxis.setNumberFormatOverride(FORMAT_P_VALUE);

        rangeAxis.setTickMarkOutsideLength(2.0f);
        rangeAxis.setMinorTickCount(2);
        rangeAxis.setMinorTickMarksVisible(true);
        rangeAxis.setAxisLineVisible(true);
        rangeAxis.setUpperMargin(0);

        TickUnitSource units = NumberAxis.createIntegerTickUnits();
        rangeAxis.setStandardTickUnits(units);

        combinedPlot.setRangeAxis(0, rangeAxis);
    }

    // Build subchart
    JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", currChrSC,
            PlotOrientation.VERTICAL, false, false, false);

    // Get subplot from subchart
    XYPlot subplot = (XYPlot) subchart.getPlot();
    subplot.setRenderer(renderer);
    subplot.setBackgroundPaint(null);

    // CHART BACKGROUD COLOR
    if (combinedPlot.getSubplots().size() % 2 == 0) {
        subplot.setBackgroundPaint(background); // Hue, saturation, brightness
    } else {
        subplot.setBackgroundPaint(backgroundAlternative); // Hue, saturation, brightness
    }

    // Add significance Threshold to subplot
    final Marker thresholdLine = new ValueMarker(threshold);
    thresholdLine.setPaint(Color.red);
    // Add legend to hetzyThreshold
    if (showlables) {
        thresholdLine.setLabel("P = " + FORMAT_P_VALUE.format(threshold));
    }
    thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    subplot.addRangeMarker(thresholdLine);

    // Chromosome Axis Labels
    NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis();
    chrAxis.setLabelAngle(1.0);
    chrAxis.setAutoRangeIncludesZero(false);
    chrAxis.setAxisLineVisible(true);

    chrAxis.setTickLabelsVisible(false);
    chrAxis.setTickMarksVisible(false);
    //      chrAxis.setNumberFormatOverride(Report_Analysis.FORMAT_SCIENTIFIC);
    //      TickUnitSource units = NumberAxis.createIntegerTickUnits();
    //      chrAxis.setStandardTickUnits(units);

    //combinedPlot.setGap(0);
    combinedPlot.add(subplot, 1);
}

From source file:net.sf.mzmine.modules.visualization.scatterplot.scatterplotchart.ScatterPlotChart.java

public ScatterPlotChart(ScatterPlotTopPanel topPanel, PeakList peakList) {

    super(null, true);

    this.peakList = peakList;
    this.topPanel = topPanel;

    // initialize the chart by default time series chart from factory
    chart = ChartFactory.createXYLineChart("", // title
            "", // x-axis label
            "", // y-axis label
            null, // data set
            PlotOrientation.VERTICAL, // orientation
            false, // create legend
            false, // generate tooltips
            false // generate URLs
    );//  w  ww  .  j  a va2s . c  o m

    chart.setBackgroundPaint(Color.white);
    setChart(chart);

    // disable maximum size (we don't want scaling)
    setMaximumDrawWidth(Integer.MAX_VALUE);
    setMaximumDrawHeight(Integer.MAX_VALUE);

    // set the plot properties
    plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
    plot.setDomainGridlinePaint(gridColor);
    plot.setRangeGridlinePaint(gridColor);

    // Set the domain log axis
    LogAxis logAxisDomain = new LogAxis();
    logAxisDomain.setMinorTickCount(1);
    logAxisDomain.setNumberFormatOverride(MZmineCore.getConfiguration().getIntensityFormat());
    logAxisDomain.setAutoRange(true);
    plot.setDomainAxis(logAxisDomain);

    // Set the range log axis
    LogAxis logAxisRange = new LogAxis();
    logAxisRange.setMinorTickCount(1);
    logAxisRange.setNumberFormatOverride(MZmineCore.getConfiguration().getIntensityFormat());
    logAxisRange.setAutoRange(true);
    plot.setRangeAxis(logAxisRange);

    // Set crosshair properties
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.setDomainCrosshairPaint(crossHairColor);
    plot.setRangeCrosshairPaint(crossHairColor);
    plot.setDomainCrosshairStroke(crossHairStroke);
    plot.setRangeCrosshairStroke(crossHairStroke);

    // Create data sets;
    mainDataSet = new ScatterPlotDataSet(peakList);
    plot.setDataset(0, mainDataSet);
    diagonalLineDataset = new DiagonalLineDataset();
    plot.setDataset(1, diagonalLineDataset);

    // Create renderers
    mainRenderer = new ScatterPlotRenderer();
    plot.setRenderer(0, mainRenderer);
    diagonalLineRenderer = new DiagonalLineRenderer();
    plot.setRenderer(1, diagonalLineRenderer);

    // Set tooltip properties
    ttm = new ComponentToolTipManager();
    ttm.registerComponent(this);
    setDismissDelay(Integer.MAX_VALUE);
    setInitialDelay(0);

    // add items to popup menu TODO: add other Show... items
    JPopupMenu popupMenu = getPopupMenu();
    popupMenu.addSeparator();
    GUIUtils.addMenuItem(popupMenu, "Show Chromatogram", this, "TIC");

}

From source file:edu.fullerton.viewerplugin.XYPlotter.java

private ChartPanel getPanel(double[][] data) throws WebUtilException {
    ChartPanel ret = null;// www  .j  a v  a 2  s .  co m
    try {
        XYSeries xys;
        XYSeriesCollection mtds = new XYSeriesCollection();
        String mylegend = legend == null || legend.isEmpty() ? "series 1" : legend;

        xys = new XYSeries(legend);

        int len = data.length;
        double minx = Double.MAX_VALUE;
        double maxx = Double.MIN_VALUE;
        double miny = Double.MAX_VALUE;
        double maxy = Double.MIN_VALUE;
        boolean gotZeroX = false;
        boolean gotZeroY = false;

        for (int i = 0; i < len; i++) {
            double x = data[i][0];
            double y = data[i][1];
            if (x == 0) {
                gotZeroX = true;
            } else {
                minx = Math.min(minx, x);
                maxx = Math.max(maxx, x);
            }
            if (y == 0) {
                gotZeroY = true;
            } else {
                miny = Math.min(miny, y);
                maxy = Math.max(maxy, y);
            }
        }
        // this kludge lets us plot a 0 on a log axis
        double fakeZeroX = 0.;
        double fakeZeroY = 0.;
        if (gotZeroX) {
            if (logXaxis) {
                fakeZeroX = minx / 10;
            } else {
                minx = Math.min(0, minx);
                maxx = Math.max(0, maxx);
            }
        }
        if (gotZeroY) {
            if (logYaxis) {
                fakeZeroY = miny / 10;
            } else {
                miny = Math.min(0, miny);
                maxy = Math.max(0, maxy);
            }
        }
        for (int i = 0; i < len; i++) {
            double x = data[i][0];
            double y = data[i][1];
            x = x == 0 ? fakeZeroX : x;
            y = y == 0 ? fakeZeroY : y;
            xys.add(x, y);
        }
        mtds.addSeries(xys);

        DefaultXYDataset ds = new DefaultXYDataset();

        int exp;
        if (maxy == 0. && miny == 0.) {
            miny = -1.;
            exp = 0;
            logYaxis = false;
        } else {

            maxy = maxy > miny ? maxy : miny * 10;
            exp = PluginSupport.scaleRange(mtds, miny, maxy);
            if (!logYaxis && exp > 0) {
                yLabel += " x 1e-" + Integer.toString(exp);
            }
        }
        JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, ds, PlotOrientation.VERTICAL,
                true, false, false);
        org.jfree.chart.plot.XYPlot plot = (org.jfree.chart.plot.XYPlot) chart.getPlot();
        if (logYaxis) {
            LogAxis rangeAxis = new LogAxis(yLabel);
            double smallest = miny * Math.pow(10, exp);
            rangeAxis.setSmallestValue(smallest);
            rangeAxis.setMinorTickCount(9);

            LogAxisNumberFormat lanf = new LogAxisNumberFormat();
            lanf.setExp(exp);
            rangeAxis.setNumberFormatOverride(lanf);
            rangeAxis.setRange(smallest, maxy * Math.pow(10, exp));
            plot.setRangeAxis(rangeAxis);
        }
        if (logXaxis) {
            LogAxis domainAxis = new LogAxis(xLabel);
            domainAxis.setMinorTickCount(9);
            domainAxis.setSmallestValue(minx);
            domainAxis.setNumberFormatOverride(new LogAxisNumberFormat());
            plot.setDomainAxis(domainAxis);
        }
        ValueAxis domainAxis = plot.getDomainAxis();
        if (fmin != null && fmin > 0) {
            domainAxis.setLowerBound(fmin);
        }
        if (fmax != null && fmax > 0) {
            domainAxis.setUpperBound(fmax);
        }
        plot.setDomainAxis(domainAxis);
        plot.setDataset(0, mtds);

        // Set the line thickness
        XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
        BasicStroke str = new BasicStroke(lineThickness);
        int n = plot.getSeriesCount();
        for (int i = 0; i < n; i++) {
            r.setSeriesStroke(i, str);
        }

        if (legend == null || legend.isEmpty()) {
            chart.removeLegend();
        }
        ret = new ChartPanel(chart);
    } catch (Exception ex) {
        throw new WebUtilException("Creating spectrum plot" + ex.getLocalizedMessage());
    }
    return ret;

}

From source file:org.gwaspi.gui.reports.ManhattanPlotZoom.java

private JFreeChart createChart(XYDataset dataset, ChromosomeKey chr) {
    JFreeChart chart = ChartFactory.createScatterPlot(null, "", "P value", dataset, PlotOrientation.VERTICAL,
            true, false, false);/*from w ww .j  a va2  s .c  o  m*/

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("NO DATA");
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);

    // CHART BACKGROUD COLOR
    chart.setBackgroundPaint(Color.getHSBColor(0.1f, 0.1f, 1.0f)); // Hue, saturation, brightness
    plot.setBackgroundPaint(manhattan_back); // Hue, saturation, brightness 9

    // GRIDLINES
    plot.setDomainGridlineStroke(new BasicStroke(0.0f));
    plot.setDomainMinorGridlineStroke(new BasicStroke(0.0f));
    plot.setDomainGridlinePaint(manhattan_back.darker().darker()); // Hue, saturation, brightness 7
    plot.setDomainMinorGridlinePaint(manhattan_back); // Hue, saturation, brightness 9
    plot.setRangeGridlineStroke(new BasicStroke(0.0f));
    plot.setRangeMinorGridlineStroke(new BasicStroke(0.0f));
    plot.setRangeGridlinePaint(manhattan_back.darker().darker()); // Hue, saturation, brightness 7
    plot.setRangeMinorGridlinePaint(manhattan_back.darker()); // Hue, saturation, brightness 8

    plot.setDomainMinorGridlinesVisible(true);
    plot.setRangeMinorGridlinesVisible(true);

    // DOTS RENDERER
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, manhattan_dot);
    //      renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY);
    //      renderer.setUseOutlinePaint(true);
    // Set dot shape of the currently appended Series
    renderer.setSeriesShape(0, new Rectangle2D.Double(0.0, 0.0, 2, 2));

    renderer.setSeriesVisibleInLegend(0, false);

    NumberAxis positionAxis = (NumberAxis) plot.getDomainAxis();
    //      domainAxis.setAutoRangeIncludesZero(false);
    //      domainAxis.setTickMarkInsideLength(2.0f);
    //      domainAxis.setTickMarkOutsideLength(2.0f);
    //      domainAxis.setMinorTickCount(2);
    //      domainAxis.setMinorTickMarksVisible(true);
    positionAxis.setLabelAngle(1.0);
    positionAxis.setAutoRangeIncludesZero(false);
    positionAxis.setAxisLineVisible(true);
    positionAxis.setTickLabelsVisible(true);
    positionAxis.setTickMarksVisible(true);

    // ADD INVERSE LOG(10) Y AXIS
    LogAxis logPAxis = new LogAxis("P value");
    logPAxis.setBase(10);
    logPAxis.setInverted(true);
    logPAxis.setNumberFormatOverride(GenericReportGenerator.FORMAT_P_VALUE);

    logPAxis.setTickMarkOutsideLength(2.0f);
    logPAxis.setMinorTickCount(2);
    logPAxis.setMinorTickMarksVisible(true);
    logPAxis.setAxisLineVisible(true);
    logPAxis.setUpperMargin(0);

    TickUnitSource units = NumberAxis.createIntegerTickUnits();
    logPAxis.setStandardTickUnits(units);
    plot.setRangeAxis(0, logPAxis);

    // Add significance Threshold to subplot
    //threshold = 0.5/rdMatrixMetadata.getMarkerSetSize();  // (0.05/10? SNPs => 5*10-?)
    final Marker thresholdLine = new ValueMarker(threshold);
    thresholdLine.setPaint(Color.red);
    // Add legend to threshold
    thresholdLine.setLabel("P = " + GenericReportGenerator.FORMAT_P_VALUE.format(threshold));
    thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    plot.addRangeMarker(thresholdLine);

    // Marker label if below threshold
    XYItemRenderer lblRenderer = plot.getRenderer();

    // THRESHOLD AND SELECTED LABEL GENERATOR
    MySeriesItemLabelGenerator lblGenerator = new MySeriesItemLabelGenerator(threshold, chr);
    lblRenderer.setSeriesItemLabelGenerator(0, lblGenerator);
    lblRenderer.setSeriesItemLabelFont(0, new Font("SansSerif", Font.PLAIN, 12));
    lblRenderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.TOP_LEFT, TextAnchor.BOTTOM_LEFT, Math.PI / 4.0));

    // TOOLTIP GENERATOR
    MyXYToolTipGenerator tooltipGenerator = new MyXYToolTipGenerator(chr);

    lblRenderer.setBaseToolTipGenerator(tooltipGenerator);

    lblRenderer.setSeriesItemLabelsVisible(0, true);

    return chart;
}

From source file:edu.fullerton.viewerplugin.SpectrumPlot.java

private ChartPanel getPanel(ArrayList<ChanDataBuffer> dbufs, boolean compact) throws WebUtilException {
    ChartPanel ret = null;//  w ww. java 2  s . c o m
    try {
        float tfsMax = 0;
        for (ChanDataBuffer buf : dbufs) {
            ChanInfo ci = buf.getChanInfo();
            float fs = ci.getRate();
            tfsMax = Math.max(fs, tfsMax);
        }
        setFsMax(tfsMax);
        String gtitle = getTitle(dbufs, compact);
        int nbuf = dbufs.size();
        XYSeries[] xys = new XYSeries[nbuf];
        XYSeriesCollection mtds = new XYSeriesCollection();

        int cnum = 0;
        compact = dbufs.size() > 2 ? false : compact;
        float bw = 1.f;
        for (ChanDataBuffer dbuf : dbufs) {
            String legend = getLegend(dbuf, compact);

            xys[cnum] = new XYSeries(legend);

            bw = calcSpectrum(xys[cnum], dbuf);

            mtds.addSeries(xys[cnum]);
        }

        DefaultXYDataset ds = new DefaultXYDataset();
        String yLabel = pwrScale.toString();
        DecimalFormat dform = new DecimalFormat("0.0###");
        String xLabel;
        xLabel = String.format("Frequency Hz - (bw: %1$s, #fft: %2$,d, s/fft: %3$.2f, ov: %4$.2f)",
                dform.format(bw), nfft, secperfft, overlap);

        Double minx, miny, maxx, maxy;
        Double[] rng = new Double[4];
        if (fmin <= 0) {
            fmin = bw;
        }
        float searchFmax = fmax;
        if (fmax <= 0 || fmax == Float.MAX_VALUE) {
            fmax = tfsMax / 2;
            searchFmax = tfsMax / 2 * 0.8f;
        }
        PluginSupport.getRangeLimits(mtds, rng, 2, fmin, searchFmax);
        minx = rng[0];
        miny = rng[1];
        maxx = rng[2];
        maxy = rng[3];

        findSmallest(mtds);
        int exp;
        if (maxy == 0. && miny == 0.) {
            miny = -1.;
            exp = 0;
            logYaxis = false;
        } else {
            miny = miny > 0 ? miny : smallestY;
            maxy = maxy > 0 ? maxy : miny * 10;
            exp = PluginSupport.scaleRange(mtds, miny, maxy);
            if (!logYaxis) {
                yLabel += " x 1e-" + Integer.toString(exp);
            }
        }
        JFreeChart chart = ChartFactory.createXYLineChart(gtitle, xLabel, yLabel, ds, PlotOrientation.VERTICAL,
                true, false, false);
        XYPlot plot = (XYPlot) chart.getPlot();
        if (logYaxis) {
            LogAxis rangeAxis = new LogAxis(yLabel);
            double smallest = miny * Math.pow(10, exp);
            rangeAxis.setSmallestValue(smallest);
            rangeAxis.setMinorTickCount(9);

            LogAxisNumberFormat lanf = new LogAxisNumberFormat();
            lanf.setExp(exp);

            rangeAxis.setNumberFormatOverride(lanf);
            rangeAxis.setRange(smallest, maxy * Math.pow(10, exp));
            rangeAxis.setStandardTickUnits(LogAxis.createLogTickUnits(Locale.US));
            plot.setRangeAxis(rangeAxis);
            plot.setRangeGridlinesVisible(true);
            plot.setRangeGridlinePaint(Color.BLACK);
        }
        if (logXaxis) {
            LogAxis domainAxis = new LogAxis(xLabel);
            domainAxis.setBase(2);
            domainAxis.setMinorTickCount(9);
            domainAxis.setMinorTickMarksVisible(true);
            domainAxis.setSmallestValue(smallestX);
            domainAxis.setNumberFormatOverride(new LogAxisNumberFormat());
            //domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            plot.setDomainAxis(domainAxis);
            plot.setDomainGridlinesVisible(true);
            plot.setDomainGridlinePaint(Color.BLACK);
        }
        ValueAxis domainAxis = plot.getDomainAxis();
        if (fmin > Float.MIN_VALUE) {
            domainAxis.setLowerBound(fmin);
        }
        if (fmax != Float.MAX_VALUE) {
            domainAxis.setUpperBound(fmax);
        }
        plot.setDomainAxis(domainAxis);
        plot.setDataset(0, mtds);
        plot.setDomainGridlinePaint(Color.DARK_GRAY);
        plot.setRangeGridlinePaint(Color.DARK_GRAY);

        // Set the line thickness
        XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
        BasicStroke str = new BasicStroke(lineThickness);
        int n = plot.getSeriesCount();
        for (int i = 0; i < n; i++) {
            r.setSeriesStroke(i, str);
        }
        plot.setBackgroundPaint(Color.WHITE);
        if (compact) {
            chart.removeLegend();
        }
        ret = new ChartPanel(chart);
    } catch (Exception ex) {
        throw new WebUtilException("Creating spectrum plot" + ex.getLocalizedMessage());
    }
    return ret;

}