List of usage examples for org.jfree.chart.axis NumberAxis setAutoRange
public void setAutoRange(boolean auto)
From source file:pwm.visualizer.MDPPolicyPanel.java
private JFreeChart createChart() { NumberAxis nutritionAxis = new NumberAxis("Calories/Day"); nutritionAxis.setLowerBound(0);/* ww w. j ava 2s . c o m*/ nutritionAxis.setUpperBound(5000); nutritionAxis.setAutoRange(false); // CategoryPlot categoryplot = new CategoryPlot(nutritionDataSet, new CategoryAxis("Weight(KG)"), nutritionAxis, new BarRenderer()); CategoryAxis xaxis = categoryplot.getDomainAxis(); xaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); LegendItemCollection legend = new LegendItemCollection(); LegendItem nutritionLegend = new LegendItem("Calories/Day"); LegendItem exerciseLegend = new LegendItem("Physical Activity Level"); nutritionLegend.setFillPaint(Color.BLUE); exerciseLegend.setFillPaint(Color.RED); legend.add(nutritionLegend); legend.add(exerciseLegend); categoryplot.setFixedLegendItems(legend); JFreeChart jfreechart = new JFreeChart("Policy Visualizer", categoryplot); categoryplot.setDataset(1, exerciseDataSet); categoryplot.mapDatasetToRangeAxis(1, 1); NumberAxis exerciseAxis = new NumberAxis("Physical Activity Level"); exerciseAxis.setLowerBound(0); exerciseAxis.setUpperBound(3.0); exerciseAxis.setAutoRange(false); categoryplot.setRangeAxis(1, exerciseAxis); BarRenderer barrenderer1 = new BarRenderer(); categoryplot.setRenderer(1, barrenderer1); // BarRenderer stackedbarrenderer = (BarRenderer)categoryplot.getRenderer(); // stackedbarrenderer.setDrawBarOutline(true); // stackedbarrenderer.setBaseItemLabelsVisible(false); // stackedbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:jmbench.plots.OperationsVersusSizePlot.java
public void setRange(double min, double max) { NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRange(false); axis.setRange(min, max);//w w w . j a v a2s . co m }
From source file:ui.FitnessGraph.java
/** * Creates a chart.//from ww w. j a v a2 s .c om * * @param dataset * the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createScatterPlot("Fitness v generation", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); // renderer.setSeriesShape(0, new Ellipse2D.Float(1.0f, 1.0f, 1.0f, // 1.0f)); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, false); // renderer.setSeriesStroke(1, new BasicStroke(0.01f)); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRange(true); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:de.fub.maps.project.detector.model.inference.ui.charts.PrecisionRecallBarChartPanel.java
/** * Creates new form PrecisionRecallBarChartPanel *//*from ww w. j a v a 2s . co m*/ public PrecisionRecallBarChartPanel() { super(); initComponents(); barChart = ChartFactory.createBarChart( NbBundle.getMessage(PrecisionRecallBarChartPanel.class, "CLT_Chart_Precision_Recall_Name"), NbBundle.getMessage(PrecisionRecallBarChartPanel.class, "CLT_Doman_Axis_Name"), NbBundle.getMessage(PrecisionRecallBarChartPanel.class, "CLT_Value_Axis_Name"), dataset, PlotOrientation.VERTICAL, true, true, true); Font font = new JLabel().getFont().deriveFont(Font.BOLD, 14); barChart.getTitle().setFont(font); barChart.getTitle().setPaint(new Color(153, 153, 153)); plot = barChart.getCategoryPlot(); NumberAxis preciAxis = new NumberAxis( NbBundle.getMessage(PrecisionRecallBarChartPanel.class, "CLT_Value_Axis_Name")); preciAxis.setAutoRange(true); preciAxis.setUpperMargin(.20); plot.setRangeAxis(0, preciAxis); plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT); plot.setBackgroundPaint(Color.white); BarRenderer barRenderer = new BarRenderer(); barRenderer.setBarPainter(new StandardBarPainter()); barRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, new CustomNumberFormat())); barRenderer.setBaseItemLabelsVisible(true); barRenderer.setSeriesPaint(0, precColor); barRenderer.setSeriesPaint(1, recColor); plot.setRenderer(barRenderer); chartPanel = new ChartPanel(barChart, false); chartPanel.setVerticalAxisTrace(false); add(chartPanel, BorderLayout.CENTER); }
From source file:com.bt.aloha.batchtest.Chart.java
private JFreeChart createChart(XYDataset xydataset, String title, String xLabel, String yLabel) { JFreeChart jfreechart = ChartFactory.createXYLineChart(title, xLabel, yLabel, xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); if (xydataset instanceof IntervalXYDataset) { DeviationRenderer deviationrenderer = new DeviationRenderer(true, true); deviationrenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesFillPaint(0, new Color(255, 200, 200)); xyplot.setRenderer(deviationrenderer); }//from ww w . ja va 2 s . co m NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setAutoRange(true); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:com.att.aro.ui.view.diagnostictab.CreateBarPlot.java
/** * Returns a XYPlot //from w ww .ja va 2 s.c o m * * @return XYPlot. */ //createWakelockStatePlot color is yellow, other is gray, createAlarmPlot need to set numberAxis, create usereventplot //createBurstPlot(),createRrcPlot() public XYPlot drawXYBarPlot(Color color, boolean setAxis) { // Create renderer XYBarRenderer barRenderer = new XYBarRenderer(); barRenderer.setDrawBarOutline(false); barRenderer.setUseYInterval(true); barRenderer.setBasePaint(color); barRenderer.setAutoPopulateSeriesPaint(false); barRenderer.setShadowVisible(false); barRenderer.setGradientPaintTransformer(null); barRenderer.setBarPainter(new StandardXYBarPainter()); NumberAxis axis = new NumberAxis(); if (setAxis) { axis.setVisible(false); axis.setAutoRange(false); axis.setRange(0, 1); } // Create result plot XYPlot barPlot = new XYPlot(null, null, axis, barRenderer); barPlot.getRangeAxis().setVisible(false); return barPlot; }
From source file:com.thalesgroup.hudson.plugins.klocwork.graph.KloTrendGraph.java
@Override protected JFreeChart createGraph() { final JFreeChart chart = ChartFactory.createLineChart(null, // chart title null, // unused yLabel, // range axis label categoryDataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls );//from w w w . ja v a 2 s. co m // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); 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.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(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerBound(0); rangeAxis.setAutoRange(true); final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseStroke(new BasicStroke(2.0f)); ColorPalette.apply(renderer); // crop extra space around the graph plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0)); return chart; }
From source file:org.jenkinsci.plugins.autozoil.graph.AutozoilGraph.java
/** * Creates a Autozoil trend graph/*from www .j av a 2s.c o m*/ * * @return the JFreeChart graph object */ protected JFreeChart createGraph() { final JFreeChart chart = ChartFactory.createLineChart(null, // chart title null, // unused yLabel, // range axis label categoryDataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); 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.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(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerBound(0); rangeAxis.setAutoRange(true); final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseStroke(new BasicStroke(2.0f)); ColorPalette.apply(renderer); // crop extra space around the graph plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0)); return chart; }
From source file:controletanquesproj1.Grafico.java
/** * Creates a chart.//from ww w .java 2 s . c o m * * @param _datasets * @param datasets * @param dataset the data for the chart. * * @return a chart. */ public JFreeChart createChart() { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "Amostra", // x axis label "Amplitude (V)", // y axis label getDatasets()[0], // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.getRangeAxis(0).setRange(-30, 30); final NumberAxis axis2 = new NumberAxis("Altura (cm)"); axis2.setAutoRange(true); axis2.setAutoRangeIncludesZero(false); //axis2.setRange(-4.9, 34.9); plot.setRangeAxis(1, axis2); plot.setDataset(1, getDatasets()[1]); plot.mapDatasetToRangeAxis(1, 1); /* getRenderer().setSeriesLinesVisible(0, true); getRenderer().setSeriesShapesVisible(0, false); getRenderer().setSeriesShapesVisible(1, false); getRenderer().setSeriesShapesVisible(2, false); getRenderer().setSeriesLinesVisible(3, true); getRenderer().setSeriesShapesVisible(3, false); */ renderer[0].setBaseShapesVisible(false); renderer[0].setAutoPopulateSeriesPaint(true); plot.setRenderer(renderer[0]); renderer[1] = new XYLineAndShapeRenderer(); renderer[1].setBaseLinesVisible(true); renderer[1].setBaseShapesVisible(true); plot.setRenderer(1, renderer[1]); // change the auto tick unit selection to integer units only... //final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); //rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:hudson.plugins.testlink.TestLinkGraph.java
/** * Creates TestLink trend graph./*from ww w . java 2s . c om*/ * * @return the JFreeChart graph object. */ protected JFreeChart createGraph() { final JFreeChart chart = ChartFactory.createLineChart(null, null, yLabel, categoryDataset, PlotOrientation.VERTICAL, true, true, false); final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setForegroundAlpha(0.8f); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.darkGray); final CategoryAxis domainAxis = new ShiftedCategoryAxis(xLabel); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); plot.setDomainAxis(domainAxis); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRange(true); rangeAxis.setAutoRangeMinimumSize(5); rangeAxis.setLowerBound(0); final CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesStroke(0, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(0, new Color(35, 20, 89)); renderer.setSeriesStroke(1, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(1, new Color(0, 145, 0)); renderer.setSeriesStroke(2, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(2, new Color(207, 69, 21)); renderer.setSeriesStroke(3, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(3, Color.orange); plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0)); return chart; }