Example usage for org.jfree.chart.axis NumberAxis setStandardTickUnits

List of usage examples for org.jfree.chart.axis NumberAxis setStandardTickUnits

Introduction

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

Prototype

public void setStandardTickUnits(TickUnitSource source) 

Source Link

Document

Sets the source for obtaining standard tick units for the axis and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:net.vanosten.dings.swing.SummaryView.java

/**
 * Creates a sample chart.//from   ww  w  .  j  a v  a2s.c  om
 *
 * @param dataset  the dataset.
 *
 * @return The chart.
 */
public void displayHorizontalBarChart(final CategoryDataset dataset, final String title,
        final String categoryTitle, final String valueTitle) {
    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart(title // chart title
            , categoryTitle // domain axis label
            , valueTitle // range axis label
            , dataset // data
            , PlotOrientation.HORIZONTAL // orientation
            , true // include legend
            , true // tooltips?
            , false // URLs?
    );
    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

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

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

    placeChart(chart);
}

From source file:fungus.PeerRatioChartFrame.java

public PeerRatioChartFrame(String prefix) {
    simulationCycles = Configuration.getDouble(PAR_SIMULATION_CYCLES);
    this.setTitle("MycoNet Statistics Chart");
    graph = JungGraphObserver.getGraph();

    //data.add(-1,0);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.setAutoWidth(false);//from   w w w. j  a  v a 2s  .c  o m
    dataset.setIntervalWidth(simulationCycles);

    //averageUtilizationData = new XYSeries("Average Utilization");
    //dataset.addSeries(averageUtilizationData);
    //averageStableUtilizationData = new XYSeries("Avg Stable Util");
    //dataset.addSeries(averageStableUtilizationData);
    bulwarkRatioData = new XYSeries("Bulwark Ratio");
    dataset.addSeries(bulwarkRatioData);
    biomassRatioData = new XYSeries("Biomass Ratio");
    dataset.addSeries(biomassRatioData);
    hyphaRatioData = new XYSeries("Hypha Ratio");
    dataset.addSeries(hyphaRatioData);
    // stableHyphaRatioData = new XYSeries("Stable Hypha Ratio");
    // dataset.addSeries(stableHyphaRatioData);

    //XYSeriesCollection dataset;

    JFreeChart peerRatioChart = ChartFactory.createXYLineChart("Bulwark Metrics", "Cycle", "Peer State Ratio",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    ChartPanel peerRatioChartPanel = new ChartPanel(peerRatioChart);

    XYPlot xyplot = peerRatioChart.getXYPlot();

    NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis();
    NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setRange(0, 1);

    //chart.setBackgroundPaint(Color.white);
    //XYPlot plot = chart.getXYPlot();

    //        BufferedImage chartImage = chart.createBufferedImage(500,300);
    //        chartLabel = new JLabel();
    //chartLabel.setIcon(new ImageIcon(chartImage));

    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    JPanel labelPane = new JPanel();
    labelPane.setLayout(new GridLayout(1, 1));
    //chartPane.setPreferredSize(new java.awt.Dimension(500, 300));
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

    ////contentPane.add(labelPane,BorderLayout.PAGE_START);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(peerRatioChartPanel, BorderLayout.CENTER);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    ////contentPane.add(buttonPane, BorderLayout.PAGE_END);

    //data = node.getHyphaData();
    //link = node.getHyphaLink();
    //mycocast = node.getMycoCast();

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    //chartPanel.add(chartLabel);

    /*JButton updateButton = new JButton("Refresh");
      ActionListener updater = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      refreshData();
      }
      };
      updateButton.addActionListener(updater);
            
      JButton closeButton = new JButton("Close");
      ActionListener closer = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      closeFrame();
      }
      };
      closeButton.addActionListener(closer);
            
      buttonPane.add(Box.createHorizontalGlue());
      buttonPane.add(updateButton);
      buttonPane.add(Box.createRigidArea(new Dimension(5,0)));
      buttonPane.add(closeButton);
      refreshData();
    */

    //JungGraphObserver.addChangeListener(this);

    this.pack();
    this.setVisible(true);
}

From source file:hudson.plugins.measurement_plots.Graph.java

protected org.jfree.chart.JFreeChart createGraph() {
    final org.jfree.data.category.CategoryDataset dataset = getDataSetBuilder().build();

    final org.jfree.chart.JFreeChart chart = org.jfree.chart.ChartFactory.createStackedAreaChart(title, // chart title
            null, // unused
            null, // range axis label
            dataset, // data
            org.jfree.chart.plot.PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );//from   w w  w  .  j  a v  a2s.  co  m

    chart.setBackgroundPaint(java.awt.Color.white);

    final org.jfree.chart.plot.CategoryPlot plot = chart.getCategoryPlot();

    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(java.awt.Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    // plot.setDomainGridlinesVisible(true);
    // plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(java.awt.Color.black);

    org.jfree.chart.axis.CategoryAxis domainAxis = new hudson.util.ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(org.jfree.chart.axis.CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final org.jfree.chart.axis.NumberAxis rangeAxis = (org.jfree.chart.axis.NumberAxis) plot.getRangeAxis();
    hudson.util.ChartUtil.adjustChebyshev(dataset, rangeAxis);
    rangeAxis.setStandardTickUnits(org.jfree.chart.axis.NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRange(true);

    org.jfree.chart.renderer.category.StackedAreaRenderer areaRenderer = new hudson.util.StackedAreaRenderer2() {

        @Override
        public java.awt.Paint getItemPaint(int row, int column) {
            GraphLabel key = (GraphLabel) dataset.getColumnKey(column);
            if (key.getColor() != null) {
                return key.getColor();
            }
            return super.getItemPaint(row, column);
        }

        @Override
        public String generateURL(org.jfree.data.category.CategoryDataset dataset, int row, int column) {
            GraphLabel label = (GraphLabel) dataset.getColumnKey(column);
            return label.getUrl();
        }

        @Override
        public String generateToolTip(org.jfree.data.category.CategoryDataset dataset, int row, int column) {
            GraphLabel label = (GraphLabel) dataset.getColumnKey(column);
            return label.getToolTip();
        }
    };
    plot.setRenderer(areaRenderer);
    areaRenderer.setSeriesPaint(2, hudson.util.ColorPalette.BLUE);

    // crop extra space around the graph
    plot.setInsets(new org.jfree.ui.RectangleInsets(0, 0, 0, 5.0));

    return chart;
}

From source file:io.narayana.perf.product.BarChart.java

public JFreeChart generateChart(String title, String xaxisLabel, String yaxisLabel) {
    JFreeChart chart = ChartFactory.createBarChart(title, xaxisLabel, yaxisLabel, dataset,
            PlotOrientation.VERTICAL, true, false, false);
    CategoryPlot plot = chart.getCategoryPlot();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinesVisible(true);

    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);

    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());

    BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer();

    for (int i = 0; i < dataset.getRowCount(); i++) {
        Color color = i < COLORS.length ? COLORS[i] : COLORS[0];
        renderer.setSeriesPaint(i, color);
    }/*from  w w w . ja  va2  s . c o  m*/

    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.demo.BarChartDemo1.java

/**
 * Creates a sample chart./*from ww w .jav  a 2s  .  c o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {
    domainLabel = "Category";
    rangeLabel = "Value";
    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            !legendPanelOn, // include legend
            true, // tooltips?
            false // URLs?
    );

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

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // 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);

    // set up gradient paints for series...
    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));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

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

    /*Summary s = new Summary(dataset);
            
            
            
      LegendTitle legend = new LegendTitle(chart.getPlot());
              
      BlockContainer wrapper = new BlockContainer(new BorderArrangement());
      wrapper.setBorder(new BlockBorder(1.0, 1.0, 1.0, 1.0));
            
    LegendItemSource[] legendSource= legend.getSources();
    LegendItemCollection old_legendItems = legendSource[0].getLegendItems();
    LegendItemCollection new_legendItems = new LegendItemCollection();
            
    int legendCount  = old_legendItems.getItemCount();
    for (int i=0; i<legendCount; i++){
       LegendItem old_legendItem = old_legendItems.get(i);
            
       String legendLabel = old_legendItem.getLabel();
       System.out.println("legendLabel="+old_legendLabel);
       LegendItem new_legendItem = new LegendItem(
                                  old_legendItem.getLabel()+s.getSummary(i),
                                  old_legendItem.getDescription(),
                                  old_legendItem.getToolTipText(),
                                  old_legendItem.getURLText(),
                                  old_legendItem.isShapeVisible(),
                                  old_legendItem.getShape(),
                                  old_legendItem.isShapeFilled(),
                                  old_legendItem.getFillPaint(),
                                  old_legendItem.isShapeOutlineVisible(),
                                  old_legendItem.getOutlinePaint(),
                                  old_legendItem.getOutlineStroke(),
                                  old_legendItem.isLineVisible(),
                                  old_legendItem.getLine(),
                                  old_legendItem.getLineStroke(),
                                  old_legendItem.getlinePaint()
                                  );
       new_legendItems.add(new_legendItem);
       }
              
            
      // *** this is important - you need to add the item container to
      // the wrapper, otherwise the legend items won't be displayed when
      // the wrapper is drawn... ***
      BlockContainer items = legend.getItemContainer();
      items.setPadding(2, 10, 5, 2);
      wrapper.add(items);
      legend.setWrapper(wrapper);
              
      legend.setPosition(RectangleEdge.BOTTOM);
      legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
      chart.addSubtitle(legend);*/

    setCategorySummary(dataset);
    return chart;

}

From source file:org.bench4Q.console.ui.section.P_WIPSSection.java

private JPanel printWIPSPic() throws IOException {
    double[][] value = wipsSmooth();
    for (int i = 0; i < value[0].length; ++i) {
        value[0][i] = i;/*from  w w  w  .  j  a  v a  2  s . c o  m*/
        // value[1][i] = webInteractionThroughput[i];.
    }

    DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
    String series1 = "Basic";
    String series2 = "real";
    // String series2 = "High";

    for (int i = 0; i < value[0].length; ++i) {
        defaultcategorydataset.addValue(value[1][i], series1, new Integer((int) value[0][i]));
        defaultcategorydataset.addValue(webInteractionThroughput[0][i], series2,
                new Integer((int) value[0][i]));
    }

    JFreeChart chart = ChartFactory.createLineChart("WIPS = " + WIPS, "time", "WIPS", defaultcategorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setBackgroundPaint(Color.WHITE);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setAutoRangeIncludesZero(true);
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setShapesVisible(false);
    lineandshaperenderer.setSeriesStroke(0, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 1F, 1F }, 0.0F));
    lineandshaperenderer.setSeriesFillPaint(0, Color.BLACK);
    lineandshaperenderer.setSeriesStroke(1,
            new BasicStroke(2.0F, 1, 0, 2.0F, new float[] { 1F, 10000F }, 0.0F));
    lineandshaperenderer.setSeriesFillPaint(0, Color.darkGray);
    return new ChartPanel(chart);
}

From source file:org.vimarsha.ui.TimeSlicedClassiferForm.java

private JFreeChart createChart(XYSeriesCollection dataSet, String chartTitle) {
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, "Time slice number", "Classification",
            dataSet, PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = chart.getXYPlot();//from   w w w  .j  a  v a 2 s .  c o m
    NumberAxis range = (NumberAxis) plot.getRangeAxis();

    range.setRange(0, 1.1);
    TickUnits units = new TickUnits();
    units.add(new NumberTickUnit(0));
    units.add(new NumberTickUnit(0.5));
    units.add(new NumberTickUnit(1));

    range.setStandardTickUnits(units);
    range.setNumberFormatOverride(new DecimalFormat() {
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
            if (number == 1)
                return toAppendTo.append("badfs");
            else if (number == 0.5)
                return toAppendTo.append("badma");
            else
                return toAppendTo.append("good");
        }
    });

    return chart;
}

From source file:hudson.plugins.labeledgroupedtests.TrendGraph.java

protected JFreeChart createGraph() {
    final CategoryDataset dataset = createDataSet().build();

    final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart
            // title
            null, // unused
            yLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );/*from w w w  .  j a  v a  2  s . co m*/

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();

    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    // plot.setDomainGridlinesVisible(true);
    // plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    ChartUtil.adjustChebyshev(dataset, rangeAxis);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRange(true);

    StackedAreaRenderer ar = new StackedAreaRenderer2() {
        @Override
        public Paint getItemPaint(int row, int column) {
            ChartLabel key = (ChartLabel) dataset.getColumnKey(column);
            if (key.getColor() != null)
                return key.getColor();
            return super.getItemPaint(row, column);
        }

        @Override
        public String generateURL(CategoryDataset dataset, int row, int column) {
            ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
            return label.getURL() + relativeUrl;
        }

        @Override
        public String generateToolTip(CategoryDataset dataset, int row, int column) {
            ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
            return label.getToolTipText();
        }
    };
    plot.setRenderer(ar);

    ar.setSeriesPaint(0, ColorPalette.RED); // Skips.
    ar.setSeriesPaint(1, ColorPalette.YELLOW); // Failures.
    ar.setSeriesPaint(2, ColorPalette.BLUE); // Total.

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    return chart;
}

From source file:org.fhaes.FHRecorder.GraphicsPanel.java

/**
 * Recalculates the charts based on the latest sample
 * data// www.java2 s  .  com
 * @return
 */
private JFreeChart updateGraph() {
    try {
        NumberAxis rangeAxis = new NumberAxis();
        XYBarRenderer renderer = new XYBarRenderer();
        renderer.setSeriesPaint(0, Color.BLUE);
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        rangeAxis.configure();

        numEventsDataset = new SlidingCategoryDataset(getNumEventsDataset(), 0, NUM_COLUMNS);
        BarRenderer numEventsRenderer = new BarRenderer();
        numEventsRenderer.setSeriesPaint(0, Color.BLUE);
        plot = new CategoryPlot(numEventsDataset, new CategoryAxis("Event Years"), rangeAxis,
                numEventsRenderer);

        numSamplesDataset = new SlidingCategoryDataset(getNumSamplesDataset(), 0, NUM_COLUMNS);
        plot.setDataset(1, numSamplesDataset);
        LineAndShapeRenderer numSamplesRenderer = new LineAndShapeRenderer();
        numSamplesRenderer.setSeriesPaint(0, Color.RED);
        plot.setRenderer(1, numSamplesRenderer);

        numRecordersDataset = new SlidingCategoryDataset(getNumRecordersDataset(), 0, NUM_COLUMNS);
        plot.setDataset(2, numRecordersDataset);
        LineAndShapeRenderer numRecordersRenderer = new LineAndShapeRenderer();
        numRecordersRenderer.setSeriesPaint(0, Color.GREEN);
        plot.setRenderer(2, numRecordersRenderer);

        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

        updateVisibleYears(savedPercent);

        return new JFreeChart(plot);
    } catch (IllegalArgumentException e) {
        // Something was wrong with the file
    }
    return null;
}

From source file:piilSource.BarChart.java

private JFreeChart createChart(String title, final CategoryDataset dataset, String metaLabel) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart(
            "Barplot of the " + metaLabel + " values for all samples - " + title, // chart title
            "Samples", // domain axis label
            metaLabel + " values", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );/*from   w  ww .java2  s. c  om*/

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.red);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    if (metaLabel.equals("beta")) {
        rangeAxis.setRange(0, 1);
        rangeAxis.setTickUnit(new NumberTickUnit(0.2));
    }

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

    // set up gradient paints for series...
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.blue);
    final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.green);
    final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.red);
    final GradientPaint gp3 = new GradientPaint(0.0f, 0.0f, Color.yellow, 0.0f, 0.0f, Color.yellow);
    final GradientPaint gp4 = new GradientPaint(0.0f, 0.0f, Color.cyan, 0.0f, 0.0f, Color.cyan);
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);
    renderer.setSeriesPaint(3, gp3);
    renderer.setSeriesPaint(4, gp4);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    if (dataset.getColumnCount() > 40) {
        domainAxis.setTickLabelFont(new Font("Serif", Font.PLAIN, 10));
        domainAxis
                .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2));
    }
    return chart;
}