long acceptedMoveCount = point.getMoveCountPerStepMeasurement().getAcceptedMoveCount(); long selectedMoveCount = point.getMoveCountPerStepMeasurement().getSelectedMoveCount(); acceptedSeries.add(timeMillisSpent, acceptedMoveCount); XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(acceptedSeries); seriesCollection.addSeries(selectedSeries); plot.setDataset(seriesIndex, seriesCollection); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer.setSeriesStroke(1, new BasicStroke( 2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] {2.0f, 6.0f}, 0.0f)); } else { renderer.setSeriesStroke(1, new BasicStroke( 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] {2.0f, 6.0f}, 0.0f)); renderer.setSeriesPaint(0, linePaint); renderer.setSeriesPaint(1, linePaint); JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " move count per step statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "MoveCountPerStepStatistic");
XYSeriesCollection seriesCollection = new XYSeriesCollection(); XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES); int seriesIndex = 0; for (Machine machine : solution.getMachineList()) { XYSeries machineSeries = new XYSeries(machine.getLabel()); for (MachineCapacity machineCapacity : machine.getMachineCapacityList()) { List<Integer> machineAvailableList = availableMap.get(machineCapacity); for (int period = 0; period < solution.getGlobalPeriodRangeTo(); period++) { int available = machineAvailableList.get(period); machineSeries.add(available, period); seriesCollection.addSeries(machineSeries); renderer.setSeriesPaint(seriesIndex, tangoColorFactory.pickColor(machine)); renderer.setSeriesShape(seriesIndex, ShapeUtilities.createDiamond(1.5F)); renderer.setSeriesVisibleInLegend(seriesIndex, false); seriesIndex++; NumberAxis domainAxis = new NumberAxis("Capacity"); return new XYPlot(seriesCollection, domainAxis, null, renderer);
private XYPlot createPeriodCostPlot(TangoColorFactory tangoColorFactory, CheapTimeSolution solution) { XYSeries series = new XYSeries("Power price"); for (PeriodPowerPrice periodPowerPrice : solution.getPeriodPowerPriceList()) { series.add((double) periodPowerPrice.getPowerPriceMicros() / 1000000.0, periodPowerPrice.getPeriod()); } XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(series); XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES); renderer.setSeriesPaint(0, TangoColorFactory.ORANGE_1); renderer.setSeriesShape(0, ShapeUtilities.createDiamond(2.0F)); NumberAxis domainAxis = new NumberAxis("Power price"); return new XYPlot(seriesCollection, domainAxis, null, renderer); }
PlotOrientation.VERTICAL, true, true, false); Shape cross = ShapeUtilities.createDiagonalCross(3, 1); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesShape(0, cross); renderer.setSeriesPaint(0, Color.red); return new ChartPanel(jfreechart); int rows = 20; double[][] values = new double[cols][rows]; XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); XYSeries series = new XYSeries("Random"); Random rand = new Random(); for (int i = 0; i < values.length; i++) { double x = rand.nextGaussian(); double y = rand.nextGaussian(); series.add(x, y); xySeriesCollection.addSeries(series); return xySeriesCollection;
renderer1.setSeriesPaint (0, Color.RED); renderer1.setSeriesPaint (1, Color.BLUE); renderer1.setSeriesPaint (2, Color.RED); renderer1.setSeriesPaint (3, Color.BLUE); renderer1.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); renderer1.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); BasicStroke dashLineStroke = new BasicStroke (2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 0, new float[] { 4 }, 0); renderer1.setSeriesStroke (2, dashLineStroke); renderer1.setSeriesStroke (3, dashLineStroke); domainAxis.setUpperMargin (0.01); NumberAxis rangeAxis = new NumberAxis("count"); rangeAxis.setStandardTickUnits (NumberAxis.createIntegerTickUnits ()); renderer2.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); renderer2.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); renderer2.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); renderer2.setSeriesPaint(0, Color.GREEN); renderer2.setSeriesPaint(1, Color.BLACK); renderer2.setSeriesPaint(2, Color.CYAN); rangeAxis = new NumberAxis("count"); chart.setBackgroundPaint (parseColor (statsManager.getChartBackgroundColor ()));
static JFreeChart getGraphic(final LegHistogram.DataFrame dataFrame, final String mode, int iteration) { final XYSeriesCollection xyData = new XYSeriesCollection(); final XYSeries departuresSerie = new XYSeries("departures", false, true); final XYSeries arrivalsSerie = new XYSeries("arrivals", false, true); final XYSeries onRouteSerie = new XYSeries("en route", false, true); int onRoute = 0; for (int i = 0; i < dataFrame.countsDep.length; i++) { xyData.addSeries(departuresSerie); xyData.addSeries(arrivalsSerie); xyData.addSeries(onRouteSerie); ); XYPlot plot = chart.getXYPlot(); plot.setDomainAxis(new NumberAxis("time")); plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0f)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray);
private static final String title = "Scatter Add Demo"; private static final Random rand = new Random(); private XYSeries added = new XYSeries("Added"); public void actionPerformed(ActionEvent e) { for (int i = 0; i < N; i++) { added.add(rand.nextDouble(), rand.nextDouble()); title, "X", "Y", createSampleData(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setRange(0.00, 1.00); domain.setTickUnit(new NumberTickUnit(0.1)); domain.setVerticalTickLabels(true); NumberAxis range = (NumberAxis) xyPlot.getRangeAxis(); range.setRange(0.0, 1.0); series.add(x, y); xySeriesCollection.addSeries(series); xySeriesCollection.addSeries(added); return xySeriesCollection;
chart.setBackgroundPaint(Color.white); chart.addSubtitle(new TextTitle(ConfigurationContext.COPYRIGHT, new Font(LABEL_FONT, Font.PLAIN, 9), Color.black, RectangleEdge.BOTTOM, HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, new RectangleInsets(0, 0, 20, 20))); for (int i = 0; i < phenomenaIds.length; i++) { axes.put(phenomenaIds[i], i); plot.setRangeAxis(i, new NumberAxis(phenomenaIds[i])); axe.setAutoRange(true); axe.setAutoRangeIncludesZero(false); } else if (prop.getAxisUpperBound() == prop.getAxisLowerBound() || prop.isAutoScale()) { if (prop.isZeroScaled()) { ValueMarker nowMarker = new ValueMarker(System.currentTimeMillis(), Color.orange, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f)); plot.addDomainMarker(nowMarker); plot.getRenderer(datasetIndex).setSeriesPaint(seriesIndex, dd.getColor()); XYURLGenerator urlGenerator = new MetadataInURLGenerator(designDescriptions); plot.getRenderer(datasetIndex).setBaseToolTipGenerator(toolTipGenerator); plot.getRenderer(datasetIndex).setURLGenerator(urlGenerator);
final Color ratioColorMax = ratioColorMin; final XYSeries seriesMinError = new XYSeries( "minError" ); final XYSeries seriesAvgError = new XYSeries( "avgError" ); final XYSeries seriesMaxError = new XYSeries( "maxError" ); final XYSeries seriesMinRatio = new XYSeries( "minRatio" ); false ); final XYPlot plot = chart.getXYPlot(); final NumberAxis axis2 = new NumberAxis( "Correspondence Ratio [%]" ); plot.getRangeAxis( 0 ).setLabelPaint( errorColorAvg ); axis2.setLabelPaint( ratioColorAvg ); axis2.setLabelFont( plot.getRangeAxis( 0 ).getLabelFont() ); axis2.setRange( 0.0, 100 ); plot.setRangeAxis( 1, axis2 ); plot.setDataset( 1, dataset2 ); plot.mapDatasetToRangeAxis( 1, 1 ); final XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint( 0, errorColorMin ); renderer.setSeriesStroke( 0, new BasicStroke ( 0.5f ) ); renderer.setSeriesPaint( 1, errorColorAvg ); renderer.setSeriesStroke( 1, new BasicStroke ( 1.5f ) ); renderer.setSeriesPaint( 2, errorColorMax ); renderer.setSeriesStroke( 2, new BasicStroke ( 0.5f ) );
for (int i = 0; i < levelValues.length && i < BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE; i++) { if (i >= seriesList.size()) { seriesList.add(new XYSeries( singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix())); seriesList.get(i).add(timeMillisSpent, levelValues[i]); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); plotList.add(createPlot(benchmarkReport, i)); plotList.get(i).setDataset(seriesIndex, new XYSeriesCollection(seriesList.get(i))); plotList.get(i).setRenderer(seriesIndex, renderer); for (int scoreLevelIndex = 0; scoreLevelIndex < plotList.size(); scoreLevelIndex++) { String scoreLevelLabel = problemBenchmarkResult.findScoreLevelLabel(scoreLevelIndex); JFreeChart chart = new JFreeChart( problemBenchmarkResult.getName() + " step " + scoreLevelLabel + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plotList.get(scoreLevelIndex), true);
private JFreeChart jFreeChart = null; private ChartPanel chartPanel = null; private XYSeries series = new XYSeries("Series"); private XYSeriesCollection collection = new XYSeriesCollection(); private XYItemEntity xyItemEntity = null; chartPanel.setMouseZoomable(false); this.info = chartPanel.getChartRenderingInfo(); XYPlot localXYPlot = (XYPlot) jFreeChart.getPlot(); XYItemRenderer localXYItemRenderer = localXYPlot.getRenderer(); localXYItemRenderer.setSeriesStroke(0, new BasicStroke(2.0F)); XYLineAndShapeRenderer localXYLineAndShapeRenderer = (XYLineAndShapeRenderer) localXYPlot.getRenderer(); localXYLineAndShapeRenderer.setBaseShapesVisible(true); localXYLineAndShapeRenderer.setSeriesFillPaint(0, Color.white); series.add(i, 4); collection.addSeries(series); return collection; XYPlot xy = jFreeChart.getXYPlot(); Rectangle2D dataArea = chartPanel.getChartRenderingInfo() .getPlotInfo().getDataArea(); dataArea, xy.getRangeAxisEdge()); double difference = finalMovePointY - initialMovePointY; if (series.getY(itemIndex).doubleValue()
public JFreeChart makeChart() { JFreeChart chart; XYSeriesCollection lineDataset = new XYSeriesCollection(); for (int i = 0; i < getSeriesNum(); i++) { lineDataset.addSeries(new XYSeries(new Integer(i))); } chart = ChartFactory.createXYLineChart("", "", "", lineDataset, PlotOrientation.VERTICAL, false, false, false); XYItemRenderer r = chart.getXYPlot().getRenderer(); for (int i = 0; i < getSeriesNum(); i++) { //int colorValue = Color.HSBtoRGB(i*17/240f, 1f,0.5f); int colorValue = Color.HSBtoRGB(((float) i) / getSeriesNum(), 1f, 0.5f); Color color = new Color(colorValue); r.setSeriesPaint(i, color); r.setSeriesStroke(i, new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER)); } NumberAxis rangeAxis = (NumberAxis) chart.getXYPlot().getRangeAxis(); rangeAxis.setNumberFormatOverride(new DecimalFormat("######.###")); NumberAxis domainAxis = (NumberAxis) chart.getXYPlot().getDomainAxis(); if (autoRange) { rangeAxis.setAutoRange(true); domainAxis.setAutoRange(true); } else { domainAxis.setRange(xMin, xMax); rangeAxis.setRange(yMin, yMax); } return chart; }
XYPlot plot = chart.getXYPlot(); plot.getDomainAxis().setUpperMargin(0); plot.getDomainAxis().setLowerMargin(0); plot.addDomainMarker(new ValueMarker(currentReferenceLine.getValue(), currentReferenceLine.getLineColor(), new BasicStroke(currentReferenceLine.getLineWidth()))); plot.addRangeMarker(new ValueMarker(currentReferenceLine.getValue(), currentReferenceLine.getLineColor(), new BasicStroke(currentReferenceLine.getLineWidth()))); plot.getRenderer().setSeriesPaint(i, colors.get(i)); plot.getRenderer().setSeriesPaint(i, colors.get(i)); chart.getPlot().setOutlineVisible(false); chart.getPlot().setBackgroundPaint(c.getBackground()); chart.setBackgroundPaint(c.getBackground());
public static JFreeChart chartProfile(DefaultTableXYDataset dataset, ChartType type) { JFreeChart chart; switch (type) { case Line: chart = ChartFactory .createXYLineChart("TimeProfile", "Time [h]", "Values", dataset, PlotOrientation.VERTICAL, true, false, false); break; case StackedArea: chart = ChartFactory.createStackedXYAreaChart("TimeProfile", "Time [h]", "Values", dataset, PlotOrientation.VERTICAL, true, false, false); break; default: throw new IllegalArgumentException(); } XYPlot plot = chart.getXYPlot(); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); plot.setBackgroundPaint(Color.white); NumberAxis xAxis = (NumberAxis)plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis yAxis = (NumberAxis)plot.getRangeAxis(); yAxis.setAutoRange(true); XYItemRenderer renderer = plot.getRenderer(); for (int s = 0; s < dataset.getSeriesCount(); s++) { renderer.setSeriesStroke(s, new BasicStroke(2)); } return chart; }
showLegend, false, false); ((XYAreaRenderer) chart.getXYPlot().getRenderer()).setOutline(true); renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, true); renderer.setSeriesStroke(i, new BasicStroke(2)); chart.getXYPlot().setRenderer(renderer); chart.setAntiAlias(true); chart.setBackgroundPaint(new Color(backgroundColor)); for (int i = 0; i < seriesMaxCount; i++) { if (seriesColor[i] >= 0) { chart.getXYPlot().getRenderer().setSeriesPaint(i, new Color(seriesColor[i])); chart.getXYPlot().getRenderer().setSeriesOutlinePaint(i, new Color(seriesOutlineColor[i]));
XYPlot plot = (XYPlot) chart.getPlot(); Shape icon = new Ellipse2D.Double(-pointRadius, -pointRadius, pointRadius * 2, pointRadius * 2); plot.setRenderer(renderer); plot.getRenderer().setSeriesStroke(i, new BasicStroke(lineThickness)); plot.getRenderer().setSeriesShape(i, icon); ((XYLineAndShapeRenderer) plot.getRenderer()).setSeriesShapesVisible(i, true); ((XYLineAndShapeRenderer) plot.getRenderer()).setSeriesShapesFilled(i, true); plot.getRenderer().setSeriesPaint(i, colors[i]); LegendTitle legend = chart.getLegend(); Font legendFont = legend.getItemFont(); float legendFontSize = legendFont.getSize(); legend.setItemFont(newLegendFont); ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis(); Font domainAxisLabelFont = domainAxis.getLabelFont(); float domainAxisLabelFontSize = domainAxisLabelFont.getSize();
"Scatter Plot Demo", "X", "Y", samplexydataset(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setVerticalTickLabels(true); return new ChartPanel(jfreechart); int cols = 20; int rows = 20; XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); XYSeries series = new XYSeries("Random"); Random rand = new Random(); for (int i = 0; i < rows; i++) { double x = rand.nextGaussian(); double y = rand.nextGaussian(); series.add(x, y); xySeriesCollection.addSeries(series); return xySeriesCollection;
public static JFreeChart createStackedAreaChart(String title, XYSeriesCollection areaData, XYSeriesCollection lineData, String xLabel, String yLabel, ColorTheme theme) { final ValueAxis xAxis = new NumberAxis(xLabel); final ValueAxis yAxis = new NumberAxis(yLabel); XYPlot mainPlot = new XYPlot(); mainPlot.setDomainAxis(xAxis); mainPlot.setRangeAxis(yAxis); mainPlot.setForegroundAlpha(0.9f); for (int i = 0; i < areaData.getSeriesCount(); i++) { areaDs.addSeries(areaData.getSeries(i)); mainPlot.setRenderer(stackedRenderer); Color[] colors = generateJetSpectrum(areaData.getSeriesCount()); for (int i = 0; i < areaData.getSeriesCount(); i++) { stackedRenderer.setSeriesPaint(i, colors[i]); for (int i = 0; i < lineData.getSeriesCount(); i++) { lineRenderer.setSeriesPaint(i, colors[i % colors.length]); lineRenderer.setSeriesStroke(i, new BasicStroke(2f)); mainPlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true);
private XYItemRenderer getShipmentRenderer(XYSeriesCollection shipments) { XYItemRenderer shipmentsRenderer = new XYLineAndShapeRenderer(true, false); // Shapes only for (int i = 0; i < shipments.getSeriesCount(); i++) { shipmentsRenderer.setSeriesPaint(i, Color.DARK_GRAY); shipmentsRenderer.setSeriesStroke(i, new BasicStroke( 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.f, new float[]{4.0f, 4.0f}, 0.0f )); } return shipmentsRenderer; }
plot.setDataset(seriesIndex, dataset); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); plot.setRenderer(seriesIndex, renderer); seriesIndex++; JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " best solution mutation statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "BestSolutionMutationStatistic");