Example usage for org.jfree.chart.axis CategoryAxis setCategoryLabelPositions

List of usage examples for org.jfree.chart.axis CategoryAxis setCategoryLabelPositions

Introduction

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

Prototype

public void setCategoryLabelPositions(CategoryLabelPositions positions) 

Source Link

Document

Sets the category label position specification for the axis and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:mzmatch.ipeak.normalisation.VanDeSompele.java

public static void main(String args[]) {
    try {/*from w  ww.  j  a  va2  s .c  o m*/
        Tool.init();

        // parse the commandline options
        Options options = new Options();
        CmdLineParser cmdline = new CmdLineParser(options);

        // check whether we need to show the help
        cmdline.parse(args);
        if (options.help) {
            Tool.printHeader(System.out, application, version);
            cmdline.printUsage(System.out, "");
            return;
        }

        if (options.verbose) {
            Tool.printHeader(System.out, application, version);
            cmdline.printOptions();
        }

        // check the command-line parameters
        {
            // if the output directories do not exist, create them
            if (options.output != null)
                Tool.createFilePath(options.output, true);
        }

        // load the data
        if (options.verbose)
            System.out.println("Loading data");
        ParseResult result = PeakMLParser.parse(new FileInputStream(options.input), true);

        Header header = result.header;
        IPeakSet<IPeakSet<? extends IPeak>> peaksets = (IPeakSet<IPeakSet<? extends IPeak>>) result.measurement;

        int nrmeasurements = header.getNrMeasurementInfos();

        // remove the stability factor annotation
        for (IPeak peak : peaksets)
            peak.removeAnnotation("stability factor");

        // load the database
        if (options.verbose)
            System.out.println("Loading the molecule database");
        HashMap<String, Molecule> database = MoleculeIO.parseXml(new FileInputStream(options.database));

        // filter the set to include only identifiable metabolites
        if (options.verbose)
            System.out.println("Creating selection");
        Vector<IPeakSet<? extends IPeak>> selection = new Vector<IPeakSet<? extends IPeak>>();
        for (Molecule molecule : database.values()) {
            double mass = molecule.getMass(Mass.MONOISOTOPIC);
            double delta = PeriodicTable.PPM(mass, options.ppm);

            // get the most intense peak containing all the measurements
            Vector<IPeakSet<? extends IPeak>> neighbourhoud = peaksets.getPeaksInMassRange(mass - delta,
                    mass + delta);
            Collections.sort(neighbourhoud, IPeak.sort_intensity_descending);
            for (IPeakSet<? extends IPeak> neighbour : neighbourhoud)
                if (count(neighbour) == nrmeasurements) {
                    selection.add(neighbour);
                    break;
                }
        }

        // calculate the stability factor for each peak in the selection
        if (options.verbose)
            System.out.println("Calculating stability factors");
        for (int peakid1 = 0; peakid1 < selection.size(); ++peakid1) {
            double stddeviations[] = new double[selection.size()];

            IPeakSet<? extends IPeak> peakset1 = selection.get(peakid1);
            for (int peakid2 = 0; peakid2 < selection.size(); ++peakid2) {
                IPeakSet<? extends IPeak> peakset2 = selection.get(peakid2);

                double values[] = new double[nrmeasurements];
                for (int measurementid = 0; measurementid < nrmeasurements; ++measurementid) {
                    int measurementid1 = peakset1.get(measurementid).getMeasurementID();
                    int setid1 = header.indexOfSetInfo(header.getSetInfoForMeasurementID(measurementid1));
                    int measurementid2 = peakset2.get(measurementid).getMeasurementID();
                    int setid2 = header.indexOfSetInfo(header.getSetInfoForMeasurementID(measurementid2));
                    if (setid1 != setid2 || measurementid1 != measurementid2)
                        System.err.println("[WARNING]: differing setid or spectrumid for comparison");

                    values[measurementid] = Math.log(peakset1.get(measurementid).getIntensity()
                            / peakset2.get(measurementid).getIntensity()) / Math.log(2);
                }
                stddeviations[peakid2] = Statistical.stddev(values);
            }

            peakset1.addAnnotation("stability factor", Statistical.mean(stddeviations));
        }

        // sort on the stability factor
        Collections.sort(selection, new IPeak.AnnotationAscending("stability factor"));

        // take the top 10% and calculate the geometric mean
        if (options.verbose)
            System.out.println("Calculating normalisation factors");
        int nrselected = (int) (0.1 * selection.size());
        if (nrselected < 10)
            nrselected = (10 < selection.size() ? 10 : selection.size());
        double normalization_factors[] = new double[nrmeasurements];
        for (int measurementid = 0; measurementid < nrmeasurements; ++measurementid) {
            double values[] = new double[nrselected];
            for (int i = 0; i < nrselected; ++i) {
                IPeak peak = selection.get(i).get(measurementid);
                values[i] = peak.getIntensity();
            }
            normalization_factors[measurementid] = Statistical.geomean(values);
        }

        // scale the found normalization factors
        double maxnf = Statistical.max(normalization_factors);
        for (int sampleid = 0; sampleid < nrmeasurements; ++sampleid)
            normalization_factors[sampleid] /= maxnf;

        // write the selection if needed
        if (options.selection != null) {
            if (options.verbose)
                System.out.println("Writing original selection data");

            PeakMLWriter.write(result.header, selection, null,
                    new GZIPOutputStream(new FileOutputStream(options.selection)), null);
        }

        // normalize all the peaks
        if (options.verbose)
            System.out.println("Normalizing all the entries");
        for (IPeakSet<? extends IPeak> peakset : peaksets) {
            for (int measurementid = 0; measurementid < nrmeasurements; ++measurementid) {
                // TODO why did I do this again ?
                int id = 0;
                int setid = 0;
                int spectrumid = 0;
                for (int i = 0; i < header.getNrSetInfos(); ++i) {
                    SetInfo set = header.getSetInfos().get(i);

                    if (id + set.getNrMeasurementIDs() > measurementid) {
                        setid = i;
                        spectrumid = measurementid - id;
                        break;
                    } else
                        id += set.getNrMeasurementIDs();
                }

                MassChromatogram<Peak> masschromatogram = null;
                for (IPeak p : peakset) {
                    int mymeasurementid = p.getMeasurementID();
                    int mysetid = header.indexOfSetInfo(header.getSetInfoForMeasurementID(mymeasurementid));
                    if (mysetid == setid && mymeasurementid == spectrumid) {
                        masschromatogram = (MassChromatogram<Peak>) p;
                        break;
                    }
                }
                if (masschromatogram == null)
                    continue;

                for (IPeak peak : masschromatogram.getPeaks())
                    peak.setIntensity(peak.getIntensity() / normalization_factors[measurementid]);
            }
        }

        // write the selection if needed
        if (options.selection_normalized != null) {
            if (options.verbose)
                System.out.println("Writing the normalized selection data");

            PeakMLWriter.write(result.header, selection, null,
                    new GZIPOutputStream(new FileOutputStream(options.selection_normalized)), null);
        }

        // write the factors if needed
        if (options.factors != null) {
            if (options.verbose)
                System.out.println("Writing the normalization factors");

            PrintStream out = new PrintStream(options.factors);
            for (int measurementid = 0; measurementid < nrmeasurements; ++measurementid)
                out.println(header.getMeasurementInfo(measurementid).getLabel() + "\t"
                        + normalization_factors[measurementid]);
        }

        // write the plot if needed
        if (options.img != null) {
            if (options.verbose)
                System.out.println("Writing the graph");

            DefaultCategoryDataset dataset = new DefaultCategoryDataset();
            JFreeChart linechart = ChartFactory.createLineChart(null, "measurement", "normalization factor",
                    dataset, PlotOrientation.VERTICAL, false, // legend
                    false, // tooltips
                    false // urls
            );

            CategoryPlot plot = (CategoryPlot) linechart.getPlot();
            CategoryAxis axis = (CategoryAxis) plot.getDomainAxis();
            axis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
            LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();

            renderer.setSeriesShapesFilled(0, true);
            renderer.setSeriesShapesVisible(0, true);

            linechart.setBackgroundPaint(Color.WHITE);
            linechart.setBorderVisible(false);
            linechart.setAntiAlias(true);

            plot.setBackgroundPaint(Color.WHITE);
            plot.setDomainGridlinesVisible(true);
            plot.setRangeGridlinesVisible(true);

            // create the datasets
            for (int measurementid = 0; measurementid < nrmeasurements; ++measurementid)
                dataset.addValue(normalization_factors[measurementid], "",
                        header.getMeasurementInfo(measurementid).getLabel());
            JFreeChartTools.writeAsPDF(new FileOutputStream(options.img), linechart, 800, 500);
        }

        // write the normalized values
        if (options.verbose)
            System.out.println("Writing the normalized data");
        PeakMLWriter.write(result.header, peaksets.getPeaks(), null,
                new GZIPOutputStream(new FileOutputStream(options.output)), null);
    } catch (Exception e) {
        Tool.unexpectedError(e, application);
    }
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo", "Category", "Value", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
    GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
    GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0));
    barrenderer.setSeriesPaint(0, gradientpaint);
    barrenderer.setSeriesPaint(1, gradientpaint1);
    barrenderer.setSeriesPaint(2, gradientpaint2);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(
            CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D));
    return jfreechart;
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createAreaChart("Area Chart", "Category", "Value", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    TextTitle texttitle = new TextTitle(
            "An area chart demonstration.  We use this subtitle as an example of what happens when you get a really long title or subtitle.");
    texttitle.setFont(new Font("SansSerif", 0, 12));
    texttitle.setPosition(RectangleEdge.TOP);
    texttitle.setPadding(new RectangleInsets(UnitType.RELATIVE, 0.050000000000000003D, 0.050000000000000003D,
            0.050000000000000003D, 0.050000000000000003D));
    texttitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
    jfreechart.addSubtitle(texttitle);//from w w  w.j  a va2  s . co  m
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setForegroundAlpha(0.5F);
    categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(Color.white);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    categoryaxis.setLowerMargin(0.0D);
    categoryaxis.setUpperMargin(0.0D);
    categoryaxis.addCategoryLabelToolTip("Type 1", "The first type.");
    categoryaxis.addCategoryLabelToolTip("Type 2", "The second type.");
    categoryaxis.addCategoryLabelToolTip("Type 3", "The third type.");
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setLabelAngle(0.0D);
    return jfreechart;
}

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

private static JFreeChart createChart() {
    JFreeChart jfreechart = ChartFactory.createBarChart("Dual Axis Chart", "Category", "Value",
            createDataset1(), PlotOrientation.VERTICAL, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(new Color(238, 238, 255));
    categoryplot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    CategoryDataset categorydataset = createDataset2();
    categoryplot.setDataset(1, categorydataset);
    categoryplot.mapDatasetToRangeAxis(1, 1);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    NumberAxis numberaxis = new NumberAxis("Secondary");
    categoryplot.setRangeAxis(1, numberaxis);
    LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer();
    lineandshaperenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    categoryplot.setRenderer(1, lineandshaperenderer);
    categoryplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    LegendTitle legendtitle = new LegendTitle(categoryplot.getRenderer(0));
    legendtitle.setMargin(new RectangleInsets(2D, 2D, 2D, 2D));
    legendtitle.setFrame(new BlockBorder());
    LegendTitle legendtitle1 = new LegendTitle(categoryplot.getRenderer(1));
    legendtitle1.setMargin(new RectangleInsets(2D, 2D, 2D, 2D));
    legendtitle1.setFrame(new BlockBorder());
    BlockContainer blockcontainer = new BlockContainer(new BorderArrangement());
    blockcontainer.add(legendtitle, RectangleEdge.LEFT);
    blockcontainer.add(legendtitle1, RectangleEdge.RIGHT);
    blockcontainer.add(new EmptyBlock(2000D, 0.0D));
    CompositeTitle compositetitle = new CompositeTitle(blockcontainer);
    compositetitle.setPosition(RectangleEdge.BOTTOM);
    jfreechart.addSubtitle(compositetitle);
    return jfreechart;
}

From source file:userInterface.ManufactureRole.DecisionChartJPanel.java

private static JFreeChart createChart1(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Vaccine Sales", "Vaccine", "quantity", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangeCrosshairVisible(true);
    categoryplot.setRangeCrosshairPaint(Color.blue);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
    GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
    GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0));
    barrenderer.setSeriesPaint(0, gradientpaint);
    barrenderer.setSeriesPaint(1, gradientpaint1);
    barrenderer.setSeriesPaint(2, gradientpaint2);
    barrenderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}"));
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(
            CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D));
    return jfreechart;
}

From source file:org.jfree.chart.swt.demo.SWTBarChartDemo1.java

/**
 * Creates a sample chart./*  www .j av  a  2  s .  c om*/
 *
 * @param dataset  the dataset.
 *
 * @return The chart.
 */
private static JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart("SWTBarChartDemo1", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset);

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // the SWTGraphics2D class doesn't handle GradientPaint well, so
    // replace the gradient painter from the default theme with a
    // standard painter...
    renderer.setBarPainter(new StandardBarPainter());

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:eu.delving.sip.base.ReportChartHelper.java

private static JPanel finishBarChart(JFreeChart chart, Color... colors) {
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setRangePannable(true);//w  w w .j a v  a  2 s.c  o m
    if (colors.length > 0)
        plot.setRenderer(new CustomRenderer(colors));
    BarRenderer bar = (BarRenderer) plot.getRenderer();
    bar.setItemLabelAnchorOffset(9D);
    bar.setBaseItemLabelsVisible(true);
    bar.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    bar.setMaximumBarWidth(0.05);
    bar.setItemMargin(0.03D);
    bar.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(INSIDE12, CENTER_RIGHT, CENTER_RIGHT, -1.5707963267948966D));
    bar.setPositiveItemLabelPositionFallback(
            new ItemLabelPosition(OUTSIDE12, CENTER_LEFT, CENTER_LEFT, -1.5707963267948966D));
    CategoryAxis x = plot.getDomainAxis();
    x.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    x.setCategoryMargin(0.25D);
    x.setUpperMargin(0.02D);
    x.setLowerMargin(0.02D);
    NumberAxis y = (NumberAxis) plot.getRangeAxis();
    y.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    y.setUpperMargin(0.10000000000000001D);
    ChartUtilities.applyCurrentTheme(chart);
    return new ChartPanel(chart);
}

From source file:org.jfree.experimental.chart.swt.demo.SWTBarChartDemo1.java

/**
 * Creates a sample chart./*from  w  w w.j ava2  s.  com*/
 *
 * @param dataset  the dataset.
 *
 * @return The chart.
 */
private static JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart("SWTBarChartDemo1", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // the SWTGraphics2D class doesn't handle GradientPaint well, so
    // replace the gradient painter from the default theme with a
    // standard painter...
    renderer.setBarPainter(new StandardBarPainter());

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:graficos.GraficoBarras.java

private static JFreeChart crearGrafico(CategoryDataset cjto_datos) {
    JFreeChart grafico = ChartFactory.createBarChart3D("Distribucin de Recursos", // Ttulo
            "Unidad de tiempo", // Ttulo eje x
            "Recurso", // Ttulo eje y
            cjto_datos, // Datos
            PlotOrientation.VERTICAL, // Orientacin
            true, // Incluir leyenda
            true, // Incluir tooltips
            false // Incluir URLs
    );//  ww  w  .  j  a  v  a2 s.  c om
    grafico.setBackgroundPaint(new Color(240, 240, 240));
    grafico.getPlot().zoom(0.0);
    CategoryPlot ploter = (CategoryPlot) grafico.getPlot();
    NumberAxis3D rangeAxis = (NumberAxis3D) ploter.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis3D.createIntegerTickUnits());
    BarRenderer3D renderer = (BarRenderer3D) ploter.getRenderer();
    renderer.setDrawBarOutline(false);
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setItemMargin(0.0);
    CategoryAxis domainAxis = ploter.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(0.0));
    return grafico;
}

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

public static JFreeChart createChart(CategoryDataset acategorydataset[]) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Freshmeat Software Projects", "Language", "Projects",
            acategorydataset[0], PlotOrientation.VERTICAL, true, true, false);
    jfreechart.addSubtitle(new TextTitle("By Programming Language"));
    jfreechart.addSubtitle(new TextTitle("As at 5 March 2003"));
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setLowerMargin(0.02D);/*w w w  .  ja v a 2s . com*/
    categoryaxis.setUpperMargin(0.02D);
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer();
    NumberAxis numberaxis1 = new NumberAxis("Percent");
    numberaxis1.setNumberFormatOverride(NumberFormat.getPercentInstance());
    categoryplot.setRangeAxis(1, numberaxis1);
    categoryplot.setDataset(1, acategorydataset[1]);
    categoryplot.setRenderer(1, lineandshaperenderer);
    categoryplot.mapDatasetToRangeAxis(1, 1);
    categoryplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    return jfreechart;
}