List of usage examples for org.jfree.data.xy XYSeriesCollection addSeries
public void addSeries(XYSeries series)
From source file:Servizi.GraficoJ.java
/** * * Creazione del dataset da utilizzare per la generazione del grafi * * Ogni grafico ha un suo dataset specifico * * @return un dataset di default./*from w w w . j a va 2 s. c om*/ * */ private XYDataset createDataset(Double[] datiFitness, Double fitnessLinea) { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries dataLineaDef = riempiDataLineaDeformabile("Fitness Linea Deformabile", datiFitness); XYSeries dataLinea = riempiDataLinea("Fitness Linea", datiFitness, fitnessLinea); dataset.addSeries(dataLinea); dataset.addSeries(dataLineaDef); return dataset; }
From source file:eremeykin.pete.plotter.PolarPlotterTopComponent.java
protected void fillData(List<Map.Entry<Double, Double>> tmpList) { XYSeries toleranceSeries1 = new XYSeries("ei"); XYSeries toleranceSeries2 = new XYSeries("es"); XYSeries dataSeries = new XYSeries("U"); XYSeries diameter = new XYSeries("d"); Double x1 = tmpList.get(0).getKey(); Double x2 = tmpList.get(0).getKey(); double delta = x2 - x1; Double y1 = tmpList.get(0).getValue(); Double xLast = tmpList.get(tmpList.size() - 1).getKey(); tmpList.add(new AbstractMap.SimpleEntry<>(x1, y1)); double min = Double.MAX_VALUE; for (Map.Entry<Double, Double> point : tmpList) { Double xv = point.getKey(); Double yv = point.getValue(); if (yv < min) { min = yv;/*from www . j a va2s . c o m*/ } } diameter.clear(); dataSeries.clear(); toleranceSeries1.clear(); toleranceSeries2.clear(); double d = Double.valueOf(model.getParameterByID(model.getRoot(), 3).getValue()); for (Map.Entry<Double, Double> point : tmpList) { Double xv = point.getKey(); Double yv = point.getValue(); if (xv == null || yv == null) { continue; } dataSeries.add(xv * 360 / (xLast + delta), d + scale * yv); toleranceSeries1.add(xv * 360 / (xLast + delta), d + scale * Double.valueOf(model.getParameterByID(model.getRoot(), 5).getValue())); toleranceSeries2.add(xv * 360 / (xLast + delta), d + scale * Math.copySign(Double.valueOf(model.getParameterByID(model.getRoot(), 5).getValue()), -1)); diameter.add(xv * 360 / (xLast + delta), d); XYSeriesCollection ds = new XYSeriesCollection(); ds.addSeries(dataSeries); ds.addSeries(toleranceSeries1); ds.addSeries(toleranceSeries2); ds.addSeries(diameter); plot.setDataset(ds); } }
From source file:org.gephi.statistics.plugin.GraphDistance.java
private String createImageFile(TempDir tempDir, double[] pVals, String pName, String pX, String pY) { //distribution of values Map<Double, Integer> dist = new HashMap<Double, Integer>(); for (int i = 0; i < N; i++) { Double d = pVals[i];/* w w w. j a v a 2 s . c om*/ if (dist.containsKey(d)) { Integer v = dist.get(d); dist.put(d, v + 1); } else { dist.put(d, 1); } } //Distribution series XYSeries dSeries = ChartUtils.createXYSeries(dist, pName); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(dSeries); JFreeChart chart = ChartFactory.createXYLineChart(pName, pX, pY, dataset, PlotOrientation.VERTICAL, true, false, false); chart.removeLegend(); ChartUtils.decorateChart(chart); ChartUtils.scaleChart(chart, dSeries, isNormalized); return ChartUtils.renderChart(chart, pName + ".png"); }
From source file:umontreal.iro.lecuyer.charts.YListSeriesCollection.java
private void initYListSeries(double h, double[] data, int numPoints) { renderer = new XYLineAndShapeRenderer(true, false); seriesCollection = new XYSeriesCollection(); XYSeriesCollection tempSeriesCollection = (XYSeriesCollection) seriesCollection; XYSeries serie = new XYSeries(" "); for (int j = 0; j < numPoints; j++) serie.add(h * (j + 1), data[j]); tempSeriesCollection.addSeries(serie); // set default colors renderer.setSeriesPaint(0, getDefaultColor(0)); // set default plot style plotStyle = new String[1]; marksType = new String[1]; dashPattern = new String[1]; marksType[0] = " "; plotStyle[0] = "smooth"; dashPattern[0] = "solid"; }
From source file:regresiones.RegresionMultiple.java
private XYDataset createSampleDataset(Double[] estimada, Integer opcion) { XYSeries series1 = new XYSeries("X - Y"); for (Double[] dato : datos) { if (opcion.equals(1)) { series1.add(dato[0], dato[2]); } else {//ww w.ja v a 2 s. com series1.add(dato[1], dato[2]); } } XYSeries series2 = new XYSeries("X - Y estimada"); for (int i = 0; i < datos.length; i++) { if (opcion.equals(1)) series2.add(datos[i][0], estimada[i]); else series2.add(datos[i][1], estimada[i]); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); dataset.addSeries(series2); return dataset; }
From source file:regresiones.RegresionSimple.java
private XYDataset createSampleDataset() { XYSeries series1 = new XYSeries("X-Y"); for (int i = 0; i < datos.length; i++) { series1.add(datos[i][0], datos[i][1]); }/*from www . j av a2 s . c om*/ XYSeries series2 = new XYSeries("X-Y estimada"); for (int i = 0; i < datos.length; i++) { series2.add(datos[i][0], yEstimada[i]); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); dataset.addSeries(series2); return dataset; }
From source file:no.ntnu.mmfplanner.ui.graph.NpvChart.java
/** * Helper method for updateModel(). Adds the legend elements for self * funding and break even.//from w w w. j a v a 2s. c o m */ private void addLegendElements(XYSeriesCollection dataset, XYLineAndShapeRenderer renderer) { // self funding legend XYSeries selfFundingLegend = new XYSeries("Self Funding"); int series = dataset.getSeriesCount(); dataset.addSeries(selfFundingLegend); renderer.setSeriesPaint(series, Color.black); renderer.setSeriesShape(series, ShapeUtilities.createUpTriangle(3.5f)); // break even legend XYSeries breakEvenLegend = new XYSeries("Break Even"); series = dataset.getSeriesCount(); dataset.addSeries(breakEvenLegend); renderer.setSeriesPaint(series, Color.black); renderer.setSeriesShape(series, ShapeUtilities.createDiamond(3.5f)); }
From source file:org.graphstream.algorithm.measure.ChartMinMaxAverageSeriesMeasure.java
public JFreeChart createChart(PlotParameters params) throws PlotException { XYSeriesCollection minMax = new XYSeriesCollection(); XYSeriesCollection avgCol = new XYSeriesCollection(); XYPlot plot;/*w ww . j ava 2s . com*/ 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; }
From source file:org.matsim.contrib.analysis.vsp.traveltimedistance.TravelTimeValidationRunner.java
private void writeTravelTimeValidation(String folder, List<CarTrip> trips) { BufferedWriter bw = IOUtils.getBufferedWriter(folder + "/validated_trips.csv"); XYSeriesCollection times = new XYSeriesCollection(); XYSeriesCollection distances = new XYSeriesCollection(); XYSeries distancess = new XYSeries("distances", true, true); XYSeries timess = new XYSeries("times", true, true); times.addSeries(timess); distances.addSeries(distancess);/*from w ww.ja v a2 s .c o m*/ try { bw.append( "agent;departureTime;fromX;fromY;toX;toY;traveltimeActual;traveltimeValidated;traveledDistance;validatedDistance"); for (CarTrip trip : trips) { if (trip.getValidatedTravelTime() != null) { bw.newLine(); bw.append(trip.toString()); timess.add(trip.getActualTravelTime(), trip.getValidatedTravelTime()); distancess.add(trip.getTravelledDistance(), trip.getValidatedTravelDistance()); } } bw.flush(); bw.close(); final JFreeChart chart2 = ChartFactory.createScatterPlot("Travel Times", "Simulated travel time [s]", "Validated travel time [s]", times); final JFreeChart chart = ChartFactory.createScatterPlot("Travel Distances", "Simulated travel distance [m]", "Validated travel distance [m]", distances); NumberAxis yAxis = (NumberAxis) ((XYPlot) chart2.getPlot()).getRangeAxis(); NumberAxis xAxis = (NumberAxis) ((XYPlot) chart2.getPlot()).getDomainAxis(); NumberAxis yAxisd = (NumberAxis) ((XYPlot) chart.getPlot()).getRangeAxis(); NumberAxis xAxisd = (NumberAxis) ((XYPlot) chart.getPlot()).getDomainAxis(); yAxisd.setUpperBound(xAxisd.getUpperBound()); yAxis.setUpperBound(xAxis.getUpperBound()); yAxis.setTickUnit(new NumberTickUnit(500)); xAxis.setTickUnit(new NumberTickUnit(500)); XYAnnotation diagonal = new XYLineAnnotation(xAxis.getRange().getLowerBound(), yAxis.getRange().getLowerBound(), xAxis.getRange().getUpperBound(), yAxis.getRange().getUpperBound()); ((XYPlot) chart2.getPlot()).addAnnotation(diagonal); XYAnnotation diagonald = new XYLineAnnotation(xAxisd.getRange().getLowerBound(), yAxisd.getRange().getLowerBound(), xAxisd.getRange().getUpperBound(), yAxisd.getRange().getUpperBound()); ((XYPlot) chart.getPlot()).addAnnotation(diagonald); ChartUtilities.writeChartAsPNG(new FileOutputStream(folder + "/validated_traveltimes" + ".png"), chart2, 1500, 1500); ChartUtilities.writeChartAsPNG(new FileOutputStream(folder + "/validated_traveldistances.png"), chart, 1500, 1500); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:Presentation.MainWindow.java
/** Update des graphiques de temprature et d'humidit en temps rel */ public void updateGraphs(float temperature, float humidite) { XYSeriesCollection datasetT = new XYSeriesCollection(); XYSeriesCollection datasetH = new XYSeriesCollection(); seriesT.add((float) seriesT.getItemCount(), temperature); seriesH.add((float) seriesH.getItemCount(), humidite); datasetT.addSeries(seriesT); datasetH.addSeries(seriesH);/*ww w . jav a 2s . c o m*/ }