public void createBarChart(final String filename) { BarChart chart = new BarChart(TITLE, X_AXIS, Y_AXIS, new String[] {"A", "B", "C"}); chart.addSeries(SERIE_1, new double[] {1.0, 5.0, 2.0, 3.0, 4.5}); chart.addSeries(SERIE_2, new double[] {2.0, 3.0, 3.0, 1.5, 4.5}); chart.addMatsimLogo(); chart.saveAsPng(filename, 800, 600); }
/** * Creates a new BarChart with the specified category-labels. * * @param title * @param xAxisLabel * @param yAxisLabel * @param categories */ public BarChart(final String title, final String xAxisLabel, final String yAxisLabel, final String[] categories) { super(title, xAxisLabel, yAxisLabel); this.dataset = new DefaultCategoryDataset(); this.chart = createChart(title, xAxisLabel, yAxisLabel, this.dataset); this.plot = this.chart.getCategoryPlot(); this.categories = categories.clone(); addDefaultFormatting(); // leave a gap of 20% between categories (groups of bars) final CategoryAxis axis1 = this.plot.getDomainAxis(); axis1.setCategoryMargin(0.20); // leave a gap of 10% between individual bars within one category BarRenderer renderer = (BarRenderer)this.plot.getRenderer(); renderer.setItemMargin(0.10); }
categories[i++] = distanceBin.low + "\n" + " .. " + "\n" + distanceBin.high; BarChart chart = new BarChart(title, xAxisLabel, yAxisLabel, categories); CategoryPlot plot = chart.getChart().getCategoryPlot(); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setMaximumCategoryLabelLines(3); chart.addMatsimLogo(); chart.addSeries("reference share", referenceShare); chart.addSeries("simulation share", simulationShare); chart.saveAsPng(fileName + ".png", 1024, 768);