Refine search
/** * Creates a float[] time-series */ public XYDataset createDataset(Float[] ds, String label) { XYSeries observations = new XYSeries(label); int n = ds.length; for (int i = 0; i < n; i++) { observations.add(i, ds[i]); } XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(observations); return collection; }
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; }
@Override public String generateLabel(XYDataset arg0, int arg1, int arg2) { XYDataItem item = problem.getSeries(arg1).getDataItem(arg2); return labelsByDataItem.get(item); }
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); }
private XYPlot createScalabilityPlot(List<XYSeries> seriesList, String xAxisLabel, NumberFormat xAxisNumberFormat, String yAxisLabel, NumberFormat yAxisNumberFormat) { NumberAxis xAxis; if (useLogarithmicProblemScale(seriesList)) { LogarithmicAxis logarithmicAxis = new LogarithmicAxis(xAxisLabel + " (logarithmic)"); logarithmicAxis.setAllowNegativesFlag(true); xAxis = logarithmicAxis; } else { xAxis = new NumberAxis(xAxisLabel); } xAxis.setNumberFormatOverride(xAxisNumberFormat); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setNumberFormatOverride(yAxisNumberFormat); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); int seriesIndex = 0; for (XYSeries series : seriesList) { XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(series); plot.setDataset(seriesIndex, seriesCollection); XYItemRenderer renderer = createScalabilityPlotRenderer(yAxisNumberFormat); plot.setRenderer(seriesIndex, renderer); seriesIndex++; } plot.setOrientation(PlotOrientation.VERTICAL); return plot; }
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;
private JFreeChart getGraphic(final ModeData modeData, final String modeName) { 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 < modeData.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);
long timeMillisSpent = point.getTimeMillisSpent(); long scoreCalculationSpeed = point.getScoreCalculationSpeed(); series.add(timeMillisSpent, scoreCalculationSpeed); plot.setDataset(seriesIndex, new XYSeriesCollection(series)); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); plot.setRenderer(seriesIndex, renderer); seriesIndex++; JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " score calculation speed statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "ScoreCalculationSpeedStatistic");
"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;
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()); XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); XYSeries series = new XYSeries("Random"); for (int i = 0; i < N * N; i++) { double x = rand.nextDouble(); series.add(x, y); xySeriesCollection.addSeries(series); xySeriesCollection.addSeries(added); return xySeriesCollection;
XYSeries dataset = new XYSeries("Series"); for (int i = 0; i < tsData.length; i++) { dataset.add(i, (float) tsData[i]); XYSeriesCollection chartXYSeriesCollection = new XYSeriesCollection(dataset); XYSeries dot = new XYSeries("Dot"); dot.add((float) redDot, 0.0f); chartXYSeriesCollection.addSeries(dot); NumberAxis timeAxis = new NumberAxis(); timeAxis.setLabel("Time"); NumberAxis valueAxis = new NumberAxis("Values"); valueAxis.setAutoRangeIncludesZero(false); valueAxis.setLabel("Values"); XYPlot timeseriesPlot = new XYPlot(chartXYSeriesCollection, timeAxis, valueAxis, xyRenderer); JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, timeseriesPlot, false); BufferedImage objBufferedImage = chart.createBufferedImage(800, 400); ByteArrayOutputStream bas = new ByteArrayOutputStream(); try {
private static final String title = "Scatter Shape Demo"; private static final Random rand = new Random(); private final XYSeries series = new XYSeries("Data"); title, "X", "Y", createSampleData(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); xyPlot.setRenderer(new XYLineAndShapeRenderer(false, true) { axis.setRange(-3.0, 3.0); axis.setTickUnit(new NumberTickUnit(0.5)); axis.setVerticalTickLabels(vertical); XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); for (int i = 0; i < N * N; i++) { series.add(rand.nextGaussian(), rand.nextGaussian()); xySeriesCollection.addSeries(series); return xySeriesCollection;
XYSeries series1 = new XYSeries("series1"); XYSeries series2 = new XYSeries("series2"); series1.add(1000, 1000); series1.add(1150, 1150); series1.add(1250, 1250); XYSeriesCollection dataset1 = new XYSeriesCollection(); XYSeriesCollection dataset2 = new XYSeriesCollection(); dataset1.addSeries(series1); dataset2.addSeries(series2); XYPlot plot = new XYPlot(); plot.setDataset(0, dataset1); plot.setDataset(1, dataset2); splinerenderer.setSeriesFillPaint(0, Color.BLUE); plot.setRenderer(1, splinerenderer); plot.setRangeAxis(0, new NumberAxis("Series 1")); plot.setRangeAxis(1, new NumberAxis("Series 2")); plot.setDomainAxis(new NumberAxis("X Axis")); chart.setBackgroundPaint(Color.WHITE); JPanel chartPanel = new ChartPanel(chart);
XYSeries series = new XYSeries("Median"); List<Integer> bcHash = new ArrayList<Integer>(); List<String> lines = FileUtils.readLines(inFile); series.add(i - 2, drop < 0 ? 0 : drop); outFileSB.append(i - 2).append("\t").append(drop); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); XYPlot plot = (XYPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA"); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setTickMarkInsideLength(2.0f); domainAxis.setTickMarkOutsideLength(0.0f); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setTickMarkOutsideLength(0.0f); ImageIO.write(chart.createBufferedImage(600, 480), "png", trendPlot);
public JFreeChart createChart(PlotParameters params) throws PlotException { XYSeriesCollection minMax = new XYSeriesCollection(); XYSeriesCollection avgCol = new XYSeriesCollection(); XYPlot plot; XYBarRenderer r = new XYBarRenderer(); r.setBarPainter(new StandardXYBarPainter()); r.setMargin(0.35); minMax.addSeries(min); avgCol.addSeries(series); minMax.addSeries(max); JFreeChart chart = ChartFactory.createXYLineChart(params.title, params.xAxisLabel, params.yAxisLabel, avgCol, params.orientation, params.showLegend, true, false); plot = ((XYPlot) chart.getPlot()); plot.setDataset(1, minMax); plot.setRenderer(1, r); if (separateMinMaxAxis) { NumberAxis minMaxAxis = new NumberAxis("min/max"); plot.setRangeAxis(1, minMaxAxis); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.mapDatasetToRangeAxis(1, 1); } return chart; }
XYSeriesCollection dataset = new XYSeriesCollection(); int numSeries = 0; double earliestTime = Double.POSITIVE_INFINITY; XYSeries series = new XYSeries("t", false, true); for (Tuple<Id, Double> pos : entry.getValue()) { Integer stopIdx = stopIndex.get(pos.getFirst()); if (stopIdx != null) { double time = pos.getSecond().doubleValue(); series.add(stopIdx.intValue(), time); if (time < earliestTime) { earliestTime = time; dataset.addSeries(series); numSeries++; false // URLs? ); c.setBackgroundPaint(new Color(1.0f, 1.0f, 1.0f, 1.0f)); XYPlot p = (XYPlot) c.getPlot(); p.getRangeAxis().setInverted(true); p.getRangeAxis().setRange(earliestTime, latestTime); XYItemRenderer renderer = p.getRenderer(); for (int i = 0; i < numSeries; i++) { renderer.setSeriesPaint(i, Color.black);
k -> new XYSeries(point.getConstraintName() + " weight")); if (levelValues[i] != ((weightSeries.getItemCount() == 0) ? 0.0 : weightSeries.getY(weightSeries.getItemCount() - 1).doubleValue())) { weightSeries.add(timeMillisSpent, levelValues[i]); plot.setRenderer(renderer); XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (XYSeries series : constraintIdToWeightSeriesMapList.get(scoreLevelIndex).values()) { seriesCollection.addSeries(series); plot.setDataset(seriesCollection); String scoreLevelLabel = subSingleBenchmarkResult.getSingleBenchmarkResult().getProblemBenchmarkResult() .findScoreLevelLabel(scoreLevelIndex); JFreeChart chart = new JFreeChart(subSingleBenchmarkResult.getName() + " constraint match total step " + scoreLevelLabel + " diff statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
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; }
try { XYSeries series = new XYSeries("Position"); List<String> lines = FileUtils.readLines(inFile); for (String line : lines) { String x = st.nextToken(); String y = st.nextToken(); series.add(Double.valueOf(x.trim()), Double.valueOf(y.trim())); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA"); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(false); ImageIO.write(chart.createBufferedImage(600, 480), "png", outFile);
XYSeriesCollection dataset = new XYSeriesCollection(); int count = 0; TreeMap<String, XYSeries> map = new TreeMap<String, XYSeries>(); XYSeries pop = map.get(groupName); if (pop == null) { pop = new XYSeries(groupName); map.put(groupName, pop); pop.add(++count, num.doubleValue()); dataset.addSeries(it.next()); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, isGrouping()); String groupName = it.next(); Color c = ChartCategories.getColor(i); for (int j = 0; j < dataset.getSeriesCount(); j++) { XYSeries s = dataset.getSeries(j); if (s.getKey().equals(groupName)) { renderer6.setSeriesPaint(j, c); renderer6.setSeriesPaint(0, ChartCategories.getColor(0)); chart.setTextAntiAlias(false); return chart;