List of usage examples for org.jfree.chart.axis CategoryAxis setTickLabelFont
public void setTickLabelFont(Font font)
From source file:org.matsim.counts.algorithms.graphs.BoxPlotNormalizedErrorGraph.java
@SuppressWarnings("unchecked") @Override//from ww w. j a v a 2 s. c o m 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.matsim.counts.algorithms.graphs.BiasErrorGraph.java
@Override public JFreeChart createChart(final int nbr) { DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); this.errorStats = new ComparisonErrorStatsCalculator(this.ccl_); double[] meanRelError = errorStats.getMeanRelError(); // double[] meanAbsError = errorStats.getMeanAbsError(); double[] meanAbsBias = errorStats.getMeanAbsBias(); for (int h = 0; h < 24; h++) { dataset0.addValue(meanRelError[h], "Mean rel error", Integer.toString(h + 1)); // dataset1.addValue(meanAbsError[h], "Mean abs error", Integer.toString(h + 1)); dataset1.addValue(meanAbsBias[h], "Mean abs bias", Integer.toString(h + 1)); }/*from ww w . ja v a 2 s . co m*/ this.chart_ = ChartFactory.createLineChart("", "Hour", "Mean rel error [%]", dataset0, PlotOrientation.VERTICAL, true, // legend? true, // tooltips? false // URLs? ); CategoryPlot plot = this.chart_.getCategoryPlot(); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, dataset1); plot.mapDatasetToRangeAxis(1, 1); final LineAndShapeRenderer renderer = new LineAndShapeRenderer(); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); plot.setRenderer(0, renderer); final CategoryAxis axis1 = new CategoryAxis("Hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(axis1); // final ValueAxis axis2 = new NumberAxis("Mean abs {bias, error} [veh/h]"); final ValueAxis axis2 = new NumberAxis("Mean abs bias [veh/h]"); plot.setRangeAxis(1, axis2); final ValueAxis axis3 = plot.getRangeAxis(0); axis3.setRange(0.0, 100.0); final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); renderer2.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); renderer2.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); // renderer2.setSeriesPaint(0, Color.black); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); return this.chart_; }
From source file:org.matsim.counts.algorithms.graphs.BiasNormalizedErrorGraph.java
@Override public JFreeChart createChart(final int nbr) { DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); this.errorStats = new ComparisonErrorStatsCalculator(this.ccl_); double[] meanNormRelError = this.errorStats.getMeanNormRelError(); // double[] meanAbsError = this.errorStats.getMeanAbsError(); double[] meanBias = this.errorStats.getMeanBias(); for (int h = 0; h < 24; h++) { meanNormRelError[h] *= 100;/*www. j a va 2 s .c o m*/ dataset0.addValue(meanNormRelError[h], "Mean norm rel error", Integer.toString(h + 1)); // dataset1.addValue(meanAbsError[h], "Mean abs error", Integer.toString(h + 1)); dataset1.addValue(meanBias[h], "Mean bias", Integer.toString(h + 1)); } this.chart_ = ChartFactory.createLineChart("", "Hour", "Mean norm rel error [%]", dataset0, PlotOrientation.VERTICAL, true, // legend? true, // tooltips? false // URLs? ); CategoryPlot plot = this.chart_.getCategoryPlot(); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, dataset1); plot.mapDatasetToRangeAxis(1, 1); final LineAndShapeRenderer renderer = new LineAndShapeRenderer(); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); plot.setRenderer(0, renderer); final CategoryAxis axis1 = new CategoryAxis("Hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(axis1); // final ValueAxis axis2 = new NumberAxis("Mean abs {bias, error} [veh/h]"); final ValueAxis axis2 = new NumberAxis("Mean bias [veh/h]"); plot.setRangeAxis(1, axis2); final ValueAxis axis3 = plot.getRangeAxis(0); axis3.setRange(0.0, 100.0); final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); renderer2.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); renderer2.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); // renderer2.setSeriesPaint(0, Color.black); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); return this.chart_; }
From source file:org.sonar.plugins.core.charts.DistributionBarChart.java
private void configureDomainAxis(CategoryPlot plot, Font font) { CategoryAxis categoryAxis = new CategoryAxis(); categoryAxis.setTickMarksVisible(true); categoryAxis.setTickLabelFont(font); categoryAxis.setTickLabelPaint(OUTLINE_COLOR); plot.setDomainAxis(categoryAxis);//from w ww . j av a 2 s . c o m plot.setDomainGridlinesVisible(false); }
From source file:org.matsim.pt.counts.PtBiasErrorGraph.java
@Override public JFreeChart createChart(final int nbr) { DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); this.errorStats = new ComparisonErrorStatsCalculator(this.ccl_); double[] meanRelError = errorStats.getMeanRelError(); // double[] meanAbsError = errorStats.getMeanAbsError(); double[] meanAbsBias = errorStats.getMeanAbsBias(); for (int h = 0; h < 24; h++) { dataset0.addValue(meanRelError[h], "Mean rel error", Integer.toString(h + 1)); // dataset1.addValue(meanAbsError[h], "Mean abs error", // Integer.toString(h + 1)); dataset1.addValue(meanAbsBias[h], "Mean abs bias", Integer.toString(h + 1)); }//w w w . j av a 2 s .c om this.chart_ = ChartFactory.createLineChart(this.chartTitle, "Hour", "Mean rel error [%]", dataset0, PlotOrientation.VERTICAL, true, // legend? true, // tooltips? false // URLs? ); CategoryPlot plot = this.chart_.getCategoryPlot(); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, dataset1); plot.mapDatasetToRangeAxis(1, 1); final LineAndShapeRenderer renderer = new LineAndShapeRenderer(); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); plot.setRenderer(0, renderer); final CategoryAxis axis1 = new CategoryAxis("Hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(axis1); // final ValueAxis axis2 = new // NumberAxis("Mean abs {bias, error} [veh/h]"); final ValueAxis axis2 = new NumberAxis("Mean abs bias [veh/h]"); plot.setRangeAxis(1, axis2); final ValueAxis axis3 = plot.getRangeAxis(0); axis3.setRange(0.0, 100.0); final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); renderer2.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); renderer2.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); // renderer2.setSeriesPaint(0, Color.black); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); return this.chart_; }
From source file:org.matsim.pt.counts.obsolete.PtBiasErrorGraph.java
@Override @Deprecated // use standard counts package public JFreeChart createChart(final int nbr) { DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); this.errorStats = new ComparisonErrorStatsCalculator(this.ccl_); double[] meanRelError = errorStats.getMeanRelError(); // double[] meanAbsError = errorStats.getMeanAbsError(); double[] meanAbsBias = errorStats.getMeanAbsBias(); for (int h = 0; h < 24; h++) { dataset0.addValue(meanRelError[h], "Mean rel error", Integer.toString(h + 1)); // dataset1.addValue(meanAbsError[h], "Mean abs error", // Integer.toString(h + 1)); dataset1.addValue(meanAbsBias[h], "Mean abs bias", Integer.toString(h + 1)); }/* w w w. j a va 2s .c o m*/ this.chart_ = ChartFactory.createLineChart(this.chartTitle, "Hour", "Mean rel error [%]", dataset0, PlotOrientation.VERTICAL, true, // legend? true, // tooltips? false // URLs? ); CategoryPlot plot = this.chart_.getCategoryPlot(); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, dataset1); plot.mapDatasetToRangeAxis(1, 1); final LineAndShapeRenderer renderer = new LineAndShapeRenderer(); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); plot.setRenderer(0, renderer); final CategoryAxis axis1 = new CategoryAxis("Hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(axis1); // final ValueAxis axis2 = new // NumberAxis("Mean abs {bias, error} [veh/h]"); final ValueAxis axis2 = new NumberAxis("Mean abs bias [veh/h]"); plot.setRangeAxis(1, axis2); final ValueAxis axis3 = plot.getRangeAxis(0); axis3.setRange(0.0, 100.0); final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); renderer2.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); renderer2.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); // renderer2.setSeriesPaint(0, Color.black); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); return this.chart_; }
From source file:org.jfree.chart.demo.IntervalBarChartDemo1.java
/** * Creates a new demo.//from w w w . j a v a2s . co m */ public IntervalBarChartDemo1() { DefaultIntervalCategoryDataset data = null; final double[][] lows = { { -.0315, .0159, .0306, .0453, .0557 } }; final double[][] highs = { { .1931, .1457, .1310, .1163, .1059 } }; data = new DefaultIntervalCategoryDataset(lows, highs); data.setCategoryKeys(CATEGORIES); final String title = "Strategie Sicherheit"; final String xTitle = "Zeitraum (in Jahren)"; final String yTitle = "Performance"; final CategoryAxis xAxis = new CategoryAxis(xTitle); xAxis.setLabelFont(titleFont); xAxis.setTickLabelFont(labelFont); xAxis.setTickMarksVisible(false); final NumberAxis yAxis = new NumberAxis(yTitle); yAxis.setLabelFont(titleFont); yAxis.setTickLabelFont(labelFont); yAxis.setRange(-0.2, 0.40); final DecimalFormat formatter = new DecimalFormat("0.##%"); yAxis.setTickUnit(new NumberTickUnit(0.05, formatter)); final IntervalBarRenderer renderer = new IntervalBarRenderer(); renderer.setSeriesPaint(0, new Color(51, 102, 153)); // renderer.setLabelGenerator(new IntervalCategoryLabelGenerator()); renderer.setItemLabelsVisible(true); renderer.setItemLabelPaint(Color.white); final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER); renderer.setPositiveItemLabelPosition(p); final CategoryPlot plot = new CategoryPlot(data, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setOutlinePaint(Color.white); plot.setOrientation(PlotOrientation.VERTICAL); this.chart = new JFreeChart(title, titleFont, plot, false); this.chart.setBackgroundPaint(Color.white); }
From source file:Interface.ResultadoJanela.java
public JFreeChart gerarGrafico(CategoryDataset dataSet) { JFreeChart chart = ChartFactory.createBarChart3D("Resultado da Localizao de Defeitos", //Titulo " ", // Eixo X "Probabilidade (%)", //Eixo Y dataSet, // Dados para o grafico PlotOrientation.VERTICAL, //Orientacao do grafico true, true, true); // exibir: legendas, tooltips, url chart.setBackgroundPaint(Color.getHSBColor(0, 0, (float) 0.835)); // Set the background colour of the chart CategoryPlot p = chart.getCategoryPlot(); // Get the Plot object for a bar graph p.setBackgroundPaint(Color.white); // Modify the plot background p.setRangeGridlinePaint(Color.BLACK); CategoryAxis axis = p.getDomainAxis(); axis.setTickLabelFont(new Font("Helvetica", Font.PLAIN, 10)); axis.setMaximumCategoryLabelWidthRatio(1.0f); axis.setMaximumCategoryLabelLines(2); p.setDomainAxis(axis);/*w ww.j a va 2 s . com*/ return chart; }
From source file:playground.christoph.icem2011.LogLinkTravelTime.java
private void createChart(Link link, String file) { // String s = data.get(linkId).toString(); // String[] travelTimes = s.split("\n"); List<Double> etts = data.get(link.getId()); final XYSeriesCollection xyData = new XYSeriesCollection(); final XYSeries expectedTravelTimes = new XYSeries("expected travel times", false, true); final XYSeries measuredTravelTimes = new XYSeries("measured travel times", false, true); for (int i = 0; i < times.size(); i++) { double time = times.get(i); if (time > graphCutOffTime) break; // do not display values > 30h in the graph double hour = Double.valueOf(time) / 3600.0; expectedTravelTimes.add(hour, Double.valueOf(etts.get(i))); measuredTravelTimes.add(hour,/*from w ww . j a v a2 s . c o m*/ Double.valueOf(measuredTravelTime.getLinkTravelTime(link, time, null, null))); } xyData.addSeries(expectedTravelTimes); xyData.addSeries(measuredTravelTimes); // final JFreeChart chart = ChartFactory.createXYStepChart( final JFreeChart chart = ChartFactory.createXYLineChart( "Compare expected and measured travel times for link " + link.getId().toString(), "time", "travel time", xyData, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(new NumberAxis("time")); try { ChartUtilities.saveChartAsPNG(new File(file), chart, 1024, 768); } catch (IOException e) { e.printStackTrace(); } }
From source file:playground.christoph.evacuation.analysis.AgentsInEvacuationAreaActivityWriter.java
/** * @return a graphic showing the number of agents in the evacuated area *//*w w w .ja v a 2 s . c om*/ private JFreeChart getGraphic(int[] activities, int[] activitiesParticipatingAtHome, int[] activitiesParticipatingNotAtHome, int[] activitiesNotParticipatingAtHome, int[] activitiesNotParticipatingNotAtHome) { final XYSeriesCollection xyData = new XYSeriesCollection(); XYSeries dataSerie; dataSerie = new XYSeries("total activity performing agents in evacuated area", false, true); for (int i = 0; i < activities.length; i++) { double hour = i * this.binSize / 60.0 / 60.0; dataSerie.add(hour, activities[i]); } xyData.addSeries(dataSerie); dataSerie = new XYSeries("participating agents performing a home activity in evacuated area", false, true); for (int i = 0; i < activitiesParticipatingAtHome.length; i++) { double hour = i * this.binSize / 60.0 / 60.0; dataSerie.add(hour, activitiesParticipatingAtHome[i]); } xyData.addSeries(dataSerie); dataSerie = new XYSeries("participating agents performing an other activity in evacuated area", false, true); for (int i = 0; i < activitiesParticipatingNotAtHome.length; i++) { double hour = i * this.binSize / 60.0 / 60.0; dataSerie.add(hour, activitiesParticipatingNotAtHome[i]); } xyData.addSeries(dataSerie); dataSerie = new XYSeries("not participating agents performing a home activity in evacuated area", false, true); for (int i = 0; i < activitiesNotParticipatingAtHome.length; i++) { double hour = i * this.binSize / 60.0 / 60.0; dataSerie.add(hour, activitiesNotParticipatingAtHome[i]); } xyData.addSeries(dataSerie); dataSerie = new XYSeries("not participating agents performing an other activity in evacuated area", false, true); for (int i = 0; i < activitiesNotParticipatingNotAtHome.length; i++) { double hour = i * this.binSize / 60.0 / 60.0; dataSerie.add(hour, activitiesNotParticipatingNotAtHome[i]); } xyData.addSeries(dataSerie); final JFreeChart chart = ChartFactory.createXYStepChart( "activity performing agents in evacuated area, it." + this.iteration, "time", "# agents", xyData, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(new NumberAxis("time")); return chart; }