List of usage examples for org.jfree.chart.axis NumberAxis setAutoRangeIncludesZero
public void setAutoRangeIncludesZero(boolean flag)
From source file:org.schreibubi.JCombinations.logic.visitors.ChartNodesVisitor.java
public void visit(Shmoo s) throws Exception { if (s.componentSelected(this.treePaths, OurTreeNode.MYSELF | OurTreeNode.PARENTS | OurTreeNode.CHILDS)) { NumberAxis xAxis = new NumberAxis(s.getTrim() + " [" + s.getXdataDefault().getUnit() + "]"); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis( s.getMeasure() + " [" + ((Ydata) s.getYdata().get(0)).getUnit() + "]"); yAxis.setAutoRangeIncludesZero(false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRendererExtended(true, true); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); this.dutData = new ArrayList<ArrayList<Double>>(); this.dutName = new ArrayList<String>(); for (int i = 0; i < s.getChildCount(); i++) (s.getChildAt(i)).accept(this); XYSeriesCollection xyseries = new XYSeriesCollection(); ArrayList<Double> x = s.getXdataDefault().getXPositions(); for (int j = 0; j < this.dutData.size(); j++) { ArrayList<Double> y = this.dutData.get(j); XYSeries xy = new XYSeries(this.dutName.get(j)); for (int i = 0; i < y.size(); i++) xy.add(x.get(i), y.get(i)); xyseries.addSeries(xy);/*from w w w . java2s.com*/ } XYPlot plot = new XYPlot(xyseries, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); Marker marker = s.getMarker(); if (marker != null) plot.addRangeMarker(marker, Layer.BACKGROUND); ExtendedJFreeChart chart = new ExtendedJFreeChart(s.getDescription(), JFreeChart.DEFAULT_TITLE_FONT, plot, false); if (marker == null) chart.addSubtitle(new TextTitle(s.getSubtitle())); else chart.addSubtitle(new TextTitle( s.getSubtitle() + " " + s.getValueAt(3) + "/" + s.getValueAt(4) + "/" + s.getValueAt(5))); chart.setTreePath(s.getTreePath()); this.charts.add(chart); } }
From source file:org.optaplanner.benchmark.impl.statistic.bestscore.BestScoreProblemStatistic.java
private XYPlot createPlot(BenchmarkReport benchmarkReport, int scoreLevelIndex) { Locale locale = benchmarkReport.getLocale(); NumberAxis xAxis = new NumberAxis("Time spent"); xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale)); NumberAxis yAxis = new NumberAxis("Best score level " + scoreLevelIndex); yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale)); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); plot.setOrientation(PlotOrientation.VERTICAL); return plot;//from w w w .j a va 2 s .com }
From source file:openqcm.ChartDynamicData.java
public ChartDynamicData() { // add primary axis frequency TimeSeries seriesFrequency = new TimeSeries("Frequency (Hz)"); datasetFrequency = new TimeSeriesCollection(seriesFrequency); rangeAxisF = new NumberAxis("Frequency (Hz)"); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, new Color(0, 142, 192)); rangeAxisF.setAutoRangeIncludesZero(false); rangeAxisF.setAutoRange(true);//from w w w . ja v a 2 s .c o m rangeAxisF.setAutoRangeMinimumSize(50); plot.setDataset(0, datasetFrequency); plot.setRangeAxis(0, rangeAxisF); plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); plot.setRenderer(0, renderer); plot.mapDatasetToRangeAxis(0, 0); // add secondary axis temperature TimeSeries seriesTemperature = new TimeSeries("Temperature (C)"); datasetTemperature = new TimeSeriesCollection(seriesTemperature); plot.setDataset(1, datasetTemperature); NumberAxis rangeAxisT = new NumberAxis("Temperature (C)"); rangeAxisT.setAutoRangeIncludesZero(false); rangeAxisT.setAutoRange(true); rangeAxisT.setAutoRangeMinimumSize(5); plot.setRangeAxis(1, rangeAxisT); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); // custom renderer for dinamically changing temperaure rendererT.setSeriesPaint(0, new Color(255, 128, 0)); plot.setRenderer(1, rendererT); plot.mapDatasetToRangeAxis(1, 1); plotComb.add(plot); plotComb.setBackgroundPaint(Color.white); plotComb.setDomainGridlinePaint(Color.white); plotComb.setRangeGridlinePaint(Color.white); // enable panning for both axis plotComb.setRangePannable(true); plotComb.setDomainPannable(true); // set time axis properties // format time axis as hh:mm:ss SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); DateAxis axis = (DateAxis) plotComb.getDomainAxis(); axis.setDateFormatOverride(format); // default auto range domainAxis.setAutoRange(true); // init the JFreeChart JFreeChart chart = new JFreeChart(plotComb); chart.setBorderPaint(Color.lightGray); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); // set legend properties LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.TOP); legend.setItemFont(new Font("Dialog", Font.PLAIN, 9)); // constructor for org.jfree.chart.ChartPanel // ChartPanel(JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips) ChartPanel chartPanel = new ChartPanel(chart, false, true, true, true, true); // enable mouse wheel support for the chart panel chartPanel.setMouseWheelEnabled(true); this.setLayout(new BorderLayout()); // add real time chart to the frame this.add(chartPanel); this.validate(); }
From source file:org.cytoscape.dyn.internal.graphMetrics.GenerateChart.java
public JFreeChart generateTimeSeries() { dataset = new XYSeriesCollection(); XYSeries[] attributeSeries = new XYSeries[(selectedNodes.size() + selectedEdges.size()) * (checkedAttributes.size() + edgeCheckedAttributes.size())]; int j = 0;/*from ww w. j av a 2 s. c o m*/ /*creating dataseries for each node and its checked attribute and adding it to the dataset*/ for (CyNode node : selectedNodes) { // System.out.println(checkedAttributes.size()); for (int i = 0; i < checkedAttributes.size(); i++) { attributeSeries[j] = new XYSeries(dynamicNetwork.getNodeLabel(node) + checkedAttributes.get(i), false, true); // System.out.println(dynamicNetwork.getDynAttribute(node, // checkedAttributes.get(i)).getKey().getColumn()); for (DynInterval<T> interval : dynamicNetwork.getDynAttribute(node, checkedAttributes.get(i)) .getIntervalList()) { // System.out.println(interval.getOnValue()); double value; if (interval.getOnValue() instanceof Double) value = (Double) interval.getOnValue(); else value = ((Integer) interval.getOnValue()).doubleValue(); // System.out.println(value); attributeSeries[j].add(interval.getStart(), value); attributeSeries[j].add(interval.getEnd(), value); //System.out.println("interval start ="+interval.getStart()); //System.out.println("interval end ="+interval.getEnd()); //System.out.println("--------"); } dataset.addSeries(attributeSeries[j++]); } } /*creating dataseries for each edge and its checked attribute and adding it to the dataset*/ for (CyEdge edge : selectedEdges) { // System.out.println(checkedAttributes.size()); for (int i = 0; i < edgeCheckedAttributes.size(); i++) { attributeSeries[j] = new XYSeries(dynamicNetwork.getEdgeLabel(edge) + edgeCheckedAttributes.get(i), false, true); // System.out.println(dynamicNetwork.getDynAttribute(node, // checkedAttributes.get(i)).getKey().getColumn()); for (DynInterval<T> interval : dynamicNetwork.getDynAttribute(edge, edgeCheckedAttributes.get(i)) .getIntervalList()) { // System.out.println(interval.getOnValue()); double value; if (interval.getOnValue() instanceof Double) value = (Double) interval.getOnValue(); else if (interval.getOnValue() instanceof Integer) value = ((Integer) interval.getOnValue()).doubleValue(); else if (interval.getOnValue() instanceof Short) value = ((Short) interval.getOnValue()).doubleValue(); else value = ((Long) interval.getOnValue()).doubleValue(); // System.out.println(value); attributeSeries[j].add(interval.getStart(), value); attributeSeries[j].add(interval.getEnd(), value); } dataset.addSeries(attributeSeries[j++]); } } String title = "Dynamic Graph Metrics"; String xAxisLabel = "Time"; String yAxisLabel = "Centrality Value"; JFreeChart chart = ChartFactory.createXYStepChart(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, true, // legend true, // tooltips false // urls ); NumberAxis xaxis = new NumberAxis(); xaxis.setAutoRangeMinimumSize(1.0); xaxis.setLabel("Time"); chart.getXYPlot().setDomainAxis(xaxis); NumberAxis yaxis = new NumberAxis(); yaxis.setAutoRangeIncludesZero(true); yaxis.setLabel("Centrality/Attribute Value"); chart.getXYPlot().setRangeAxis(yaxis); chart.setBackgroundPaint(Color.white); //chart.setPadding(new RectangleInsets(20,20,20,20)); chart.getXYPlot().setBackgroundPaint(Color.white); chart.getXYPlot().setDomainGridlinePaint(Color.gray); chart.getXYPlot().setRangeGridlinePaint(Color.gray); return chart; }
From source file:org.matsim.counts.algorithms.graphs.BoxPlotNormalizedErrorGraph.java
@SuppressWarnings("unchecked") @Override/*ww w .j a va2 s.com*/ public JFreeChart createChart(final int nbr) { DefaultBoxAndWhiskerCategoryDataset dataset0 = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset dataset1 = new DefaultBoxAndWhiskerCategoryDataset(); final ArrayList<Double>[] listRel = new ArrayList[24]; final ArrayList<Double>[] listAbs = new ArrayList[24]; // init for (int i = 0; i < 24; i++) { listRel[i] = new ArrayList<Double>(); listAbs[i] = new ArrayList<Double>(); } // add the values of all counting stations to each hour for (CountSimComparison cc : this.ccl_) { int hour = cc.getHour() - 1; listRel[hour].add(cc.calculateNormalizedRelativeError() * 100); listAbs[hour].add(cc.getSimulationValue() - cc.getCountValue()); } // add the collected values to the graph / dataset for (int i = 0; i < 24; i++) { dataset0.add(listRel[i], "Rel Norm Error", Integer.toString(i + 1)); dataset1.add(listAbs[i], "Abs Error", Integer.toString(i + 1)); } String title = "Iteration: " + this.iteration_; final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); final CategoryAxis xAxis = new CategoryAxis("Hour"); final NumberAxis yAxis0 = new NumberAxis("Norm. Rel. Error [%]"); final NumberAxis yAxis1 = new NumberAxis("Signed Abs. Error [veh]"); yAxis0.setAutoRangeIncludesZero(false); yAxis1.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesToolTipGenerator(0, new BoxAndWhiskerToolTipGenerator()); CategoryPlot subplot0 = new CategoryPlot(dataset0, xAxis, yAxis0, renderer); CategoryPlot subplot1 = new CategoryPlot(dataset1, xAxis, yAxis1, renderer); plot.add(subplot0); plot.add(subplot1); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); axis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setDomainAxis(axis1); this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }
From source file:org.vast.stt.renderer.JFreeChart.XYPlotBuilder.java
public void addAxisToPlot(DataItem item) { String axisName = item.getName(); NumberAxis rangeAxis = new NumberAxis(axisName); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setAutoRange(false);/*from ww w. ja v a 2 s . c o m*/ NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(2); rangeAxis.setNumberFormatOverride(format); rangeAxis.setLowerBound(scene.getRangeMin()); rangeAxis.setUpperBound(scene.getRangeMax()); plot.setRangeAxis(rangeAxisCount, rangeAxis); axisTable.put(item, rangeAxisCount); rangeAxisCount++; }
From source file:no.uio.medicine.virsurveillance.charts.BoxAndWhiskerChart_AWT.java
public void updateChartData() { this.printable = false; BoxAndWhiskerCategoryDataset dataset = (BoxAndWhiskerCategoryDataset) createDataset(this.dataPoints, this.categories, this.seriesTitles); final CategoryAxis xAxis = new CategoryAxis(this.xAxisTitle); final NumberAxis yAxis = new NumberAxis(this.yAxisTitle); yAxis.setAutoRangeIncludesZero(false); this.renderer = new BoxAndWhiskerRenderer(); this.renderer.setFillBox(false); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); this.plot = new CategoryPlot(dataset, xAxis, yAxis, this.renderer); final JFreeChart chart = new JFreeChart(this.chartTitle, new Font("SansSerif", Font.BOLD, 14), this.plot, true);/*from w w w .jav a 2s . c om*/ this.plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); this.chartPanel = new ChartPanel(chart); this.chartPanel.setPreferredSize(new java.awt.Dimension(1200, 500)); setContentPane(this.chartPanel); this.pack(); this.setVisible(true); this.printable = true; }
From source file:org.matsim.counts.algorithms.graphs.BoxPlotErrorGraph.java
@SuppressWarnings("unchecked") @Override// w w w . j a v a 2 s.c om public JFreeChart createChart(final int nbr) { DefaultBoxAndWhiskerCategoryDataset dataset0 = new DefaultBoxAndWhiskerCategoryDataset(); DefaultBoxAndWhiskerCategoryDataset dataset1 = new DefaultBoxAndWhiskerCategoryDataset(); final ArrayList<Double>[] listRel = new ArrayList[24]; final ArrayList<Double>[] listAbs = new ArrayList[24]; // init for (int i = 0; i < 24; i++) { listRel[i] = new ArrayList<Double>(); listAbs[i] = new ArrayList<Double>(); } // add the values of all counting stations to each hour for (CountSimComparison cc : this.ccl_) { int hour = cc.getHour() - 1; listRel[hour].add(cc.calculateRelativeError()); listAbs[hour].add(cc.getSimulationValue() - cc.getCountValue()); } // add the collected values to the graph / dataset for (int i = 0; i < 24; i++) { dataset0.add(listRel[i], "Rel Error", Integer.toString(i + 1)); dataset1.add(listAbs[i], "Abs Error", Integer.toString(i + 1)); } String title = "Iteration: " + this.iteration_; final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); final CategoryAxis xAxis = new CategoryAxis("Hour"); final NumberAxis yAxis0 = new NumberAxis("Signed Rel. Error [%]"); final NumberAxis yAxis1 = new NumberAxis("Signed Abs. Error [veh]"); yAxis0.setAutoRangeIncludesZero(false); yAxis1.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesToolTipGenerator(0, new BoxAndWhiskerToolTipGenerator()); CategoryPlot subplot0 = new CategoryPlot(dataset0, xAxis, yAxis0, renderer); CategoryPlot subplot1 = new CategoryPlot(dataset1, xAxis, yAxis1, renderer); plot.add(subplot0); plot.add(subplot1); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); axis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setDomainAxis(axis1); this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }
From source file:edu.ucla.stat.SOCR.chart.demo.StatisticalBarChartDemo2.java
/** * Creates a sample chart.//from w ww . j av a 2 s. co m * * @param dataset a dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setErrorIndicatorPaint(Color.black); renderer.setLegendItemLabelGenerator( new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT)); plot.setRenderer(renderer); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:de.berlios.statcvs.xml.report.CommitActivityChart.java
public XYPlot createPlot(XYDataset dataset, String title) { NumberAxis valueAxis = new NumberAxis(title); valueAxis.setTickUnit(new NumberTickUnit(6.0, new DecimalFormat("0"))); valueAxis.setAutoRangeIncludesZero(false); valueAxis.setLowerBound(0);/* w ww.j a v a 2 s.c om*/ valueAxis.setUpperBound(24); valueAxis.setLabelFont(new Font("SansSerif", Font.PLAIN, 9)); return new XYPlot(dataset, null, valueAxis, new PointXYRenderer()); }