List of usage examples for org.jfree.data.xy XYSeriesCollection addSeries
public void addSeries(XYSeries series)
From source file:com.griddynamics.jagger.reporting.LatencyPlotReportProvider.java
public static XYSeriesCollection getSeriesCollection(int seriesCount) { XYSeriesCollection result = new XYSeriesCollection(); Random rnd = new Random(); for (int i = 0; i < seriesCount; i++) { XYSeries series = new XYSeries(i, false, false); result.addSeries(series); for (int t = 0; t < 100; t++) { series.add(t, rnd.nextInt(50)); }//from w ww . java 2 s .c om } return result; }
From source file:PowerMethod.power_method.java
private static XYDataset createDataSetA(List<trace_det> list) { final XYSeries data1 = new XYSeries("1"); final XYSeries data2 = new XYSeries("2"); final XYSeries data3 = new XYSeries("3"); final XYSeries data4 = new XYSeries("4"); final XYSeries data5 = new XYSeries("5"); final XYSeries data6 = new XYSeries("6"); final XYSeries data7 = new XYSeries("7"); final XYSeries data8 = new XYSeries("8"); final XYSeries data9 = new XYSeries("9"); final XYSeries data10 = new XYSeries("10"); double det;// w ww . ja va 2s. c om double trace; int n; //System.out.println("length of list: " + list.size()); for (trace_det t : list) { det = t.getDet(); trace = t.getTrace(); n = t.getIterA(); //System.out.println(n); if (n >= 1 && n <= 10) { //System.out.println("1-10"); data1.add(det, trace); } else if (n >= 11 && n <= 20) { //System.out.println("11-20"); data2.add(det, trace); } else if (n >= 21 && n <= 30) { //System.out.println("21-30"); data3.add(det, trace); } else if (n >= 31 && n <= 40) { //System.out.println("31-40"); data4.add(det, trace); } else if (n >= 41 && n <= 50) { //System.out.println("41-50"); data5.add(det, trace); } else if (n >= 51 && n <= 60) { //System.out.println("51-60"); data6.add(det, trace); } else if (n >= 61 && n <= 70) { //System.out.println("61-70"); data7.add(det, trace); } else if (n >= 71 && n <= 80) { data8.add(det, trace); } else if (n >= 81 && n <= 90) { data9.add(det, trace); } else { data10.add(det, trace); } } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(data1); dataset.addSeries(data2); dataset.addSeries(data3); dataset.addSeries(data4); dataset.addSeries(data5); dataset.addSeries(data6); dataset.addSeries(data7); dataset.addSeries(data8); dataset.addSeries(data9); dataset.addSeries(data10); return dataset; }
From source file:PowerMethod.power_method.java
private static XYDataset createDataSetAInverse(List<trace_det> list) { final XYSeries data1 = new XYSeries("1 - 10"); final XYSeries data2 = new XYSeries("11 - 20"); final XYSeries data3 = new XYSeries("21 - 30"); final XYSeries data4 = new XYSeries("31 - 40"); final XYSeries data5 = new XYSeries("41 - 50"); final XYSeries data6 = new XYSeries("51 - 60"); final XYSeries data7 = new XYSeries("61 - 70"); final XYSeries data8 = new XYSeries("71 - 80"); final XYSeries data9 = new XYSeries("81 - 90"); final XYSeries data10 = new XYSeries("91 - 100"); double det;// ww w . ja va 2 s. c o m double trace; int n; //System.out.println("length of list: " + list.size()); for (trace_det t : list) { det = t.getDet(); trace = t.getTrace(); n = t.getIterInverseA(); //System.out.println(n); if (n >= 1 && n <= 10) { //System.out.println("1-10"); data1.add(det, trace); } else if (n >= 11 && n <= 20) { //System.out.println("11-20"); data2.add(det, trace); } else if (n >= 21 && n <= 30) { //System.out.println("21-30"); data3.add(det, trace); } else if (n >= 31 && n <= 40) { //System.out.println("31-40"); data4.add(det, trace); } else if (n >= 41 && n <= 50) { //System.out.println("41-50"); data5.add(det, trace); } else if (n >= 51 && n <= 60) { //System.out.println("51-60"); data6.add(det, trace); } else if (n >= 61 && n <= 70) { //System.out.println("61-70"); data7.add(det, trace); } else if (n >= 71 && n <= 80) { data8.add(det, trace); } else if (n >= 81 && n <= 90) { data9.add(det, trace); } else { data10.add(det, trace); } } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(data1); dataset.addSeries(data2); dataset.addSeries(data3); dataset.addSeries(data4); dataset.addSeries(data5); dataset.addSeries(data6); dataset.addSeries(data7); dataset.addSeries(data8); dataset.addSeries(data9); dataset.addSeries(data10); return dataset; }
From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileChartFactory.java
public static JFreeChart createDiveProfileChartPanel(DiveProfile diveProfile, Locale locale, LengthUnit lengthUnit) {//from w ww . j a va 2s. com XYSeries depthSerie = new XYSeries(SERIE_DEPTH); XYSeriesCollection depthCollection = new XYSeriesCollection(); depthCollection.addSeries(depthSerie); JFreeChart chart = ChartFactory.createXYAreaChart(null, getDomainLegend(locale), getRangeLegend(locale, lengthUnit), depthCollection, PlotOrientation.VERTICAL, false, true, false); XYPlot xyp = chart.getXYPlot(); Paint p = new GradientPaint(0f, 0f, UIAgent.getInstance().getColorWaterBottom(), 200f, 200f, UIAgent.getInstance().getColorWaterSurface(), false); xyp.setBackgroundPaint(p); xyp.setDomainGridlinePaint(UIAgent.getInstance().getColorWaterGrid()); xyp.setRangeGridlinePaint(UIAgent.getInstance().getColorWaterGrid()); ((NumberAxis) xyp.getDomainAxis()).setNumberFormatOverride(new MinutesNumberFormat()); XYAreaRenderer renderer0 = new XYAreaRenderer(); renderer0.setOutline(true); renderer0.setBaseOutlinePaint(UIAgent.getInstance().getColorWaterBottom()); Color baseColor = UIAgent.getInstance().getColorBaseBackground(); renderer0.setSeriesPaint(0, new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), 50)); xyp.setRenderer(0, renderer0); int i = 1; XYSeriesCollection decoEntriesCollection = new XYSeriesCollection(); XYSeries decoEntriesSerie = new XYSeries(SERIE_DECO_ENTRY); decoEntriesCollection.addSeries(decoEntriesSerie); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); renderer2.setSeriesLinesVisible(0, false); renderer2.setAutoPopulateSeriesShape(false); renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorDecoEntries()); renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_DECO_ENTRY]); xyp.setDataset(i, decoEntriesCollection); xyp.setRenderer(i, renderer2); i++; XYSeriesCollection ascentTooFastCollection = new XYSeriesCollection(); XYSeries ascentTooFastSerie = new XYSeries(SERIE_WARNING_ASCENT_TOO_FAST); ascentTooFastCollection.addSeries(ascentTooFastSerie); renderer2 = new XYLineAndShapeRenderer(); renderer2.setSeriesLinesVisible(0, false); renderer2.setAutoPopulateSeriesShape(false); renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningAscentTooFast()); renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_ASCENT_TOO_FAST_WARNING]); xyp.setDataset(i, ascentTooFastCollection); xyp.setRenderer(i, renderer2); i++; XYSeriesCollection decoWarningCollection = new XYSeriesCollection(); XYSeries decoWarningSerie = new XYSeries(SERIE_DECO_STOP); decoWarningCollection.addSeries(decoWarningSerie); renderer2 = new XYLineAndShapeRenderer(); renderer2.setSeriesLinesVisible(0, false); renderer2.setAutoPopulateSeriesShape(false); renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningDecoCeiling()); renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_DECO_WARNING]); xyp.setDataset(i, decoWarningCollection); xyp.setRenderer(i, renderer2); i++; XYSeriesCollection remainBottomTimeCollection = new XYSeriesCollection(); XYSeries remainBottomTimeSerie = new XYSeries(SERIE_REMAINING_BOTTOM_TIME); remainBottomTimeCollection.addSeries(remainBottomTimeSerie); renderer2 = new XYLineAndShapeRenderer(); renderer2.setSeriesLinesVisible(0, false); renderer2.setAutoPopulateSeriesShape(false); renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningRemainingBottomTime()); renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_REMAINING_BOTTOM_TIME_WARNING]); xyp.setDataset(i, remainBottomTimeCollection); xyp.setRenderer(i, renderer2); Map<Double, Double> depthEntries = diveProfile.getDepthEntries(); Set<Double> ascentWarning = diveProfile.getAscentWarnings(); Set<Double> decoWarnings = diveProfile.getDecoCeilingWarnings(); Set<Double> remainBottomTime = diveProfile.getRemainingBottomTimeWarnings(); Set<Double> decoEntryTime = diveProfile.getDecoEntries(); if (depthEntries.size() > 0 && depthEntries.get(0d) == null) { depthEntries.put(0d, 0d); } for (Double seconds : depthEntries.keySet()) { double d = UnitsAgent.getInstance().convertLengthFromModel(depthEntries.get(seconds), lengthUnit); depthSerie.add(seconds, Double.valueOf(d)); } if (null != ascentWarning) { for (Double seconds : ascentWarning) { ascentTooFastSerie.add(seconds, depthEntries.get(seconds)); } } if (null != decoWarnings) { for (Double seconds : decoWarnings) { decoWarningSerie.add(seconds, depthEntries.get(seconds)); } } if (null != remainBottomTime) { for (Double seconds : remainBottomTime) { remainBottomTimeSerie.add(seconds, depthEntries.get(seconds)); } } if (null != decoEntryTime) { for (Double seconds : decoEntryTime) { decoEntriesSerie.add(seconds, depthEntries.get(seconds)); } } return chart; }
From source file:org.gwaspi.reports.PlinkReportLoaderCombined.java
public static CombinedRangeXYPlot loadAssocUnadjLogPvsPos(File plinkReport, Set<String> redMarkers) throws IOException { NumberAxis sharedAxis = new NumberAxis("-log?(P)"); sharedAxis.setTickMarkInsideLength(3.0f); CombinedRangeXYPlot combinedPlot = new CombinedRangeXYPlot(sharedAxis); combinedPlot.setGap(0);// w w w . j ava 2s . c o m XYSeries series1 = null; XYSeries series2 = null; FileReader inputFileReader = null; BufferedReader inputBufferReader = null; try { inputFileReader = new FileReader(plinkReport); inputBufferReader = new BufferedReader(inputFileReader); // Getting data from file and subdividing to series all points by chromosome String l; String tempChr = ""; // read but ignore the header /*String header = */inputBufferReader.readLine(); int count = 0; while ((l = inputBufferReader.readLine()) != null) { if (count % 10000 == 0) { log.info("loadAssocUnadjLogPvsPos -> reader count: {}", count); } count++; l = l.trim().replaceAll("\\s+", ","); String[] cVals = l.split(","); String markerId = cVals[1]; int position = Integer.parseInt(cVals[2]); String s_pVal = cVals[8]; if (!s_pVal.equals("NA")) { double pValue = Double.parseDouble(s_pVal); // P value if (cVals[0].toString().equals(tempChr)) { if (redMarkers.contains(markerId)) { // Insert in alternate color series series2.add(position, pValue); } else { series1.add(position, pValue); } // series1.add(position, logPValue); } else { if (!tempChr.isEmpty()) { // Not the first time round! XYSeriesCollection tempChrData = new XYSeriesCollection(); tempChrData.addSeries(series1); tempChrData.addSeries(series2); appendToCombinedRangePlot(combinedPlot, tempChr, tempChrData, false); } tempChr = cVals[0]; series1 = new XYSeries("Imputed"); series2 = new XYSeries("Observed"); // Alternate color series if (redMarkers.contains(markerId)) { // Insert inlternate color series series2.add(position, pValue); } else { series1.add(position, pValue); } // series1 = new XYSeries(cVals[0]); // series1.add(position, logPValue); } } } // Append last chromosome to combined plot XYSeriesCollection tempChrData = new XYSeriesCollection(); tempChrData.addSeries(series1); tempChrData.addSeries(series2); appendToCombinedRangePlot(combinedPlot, tempChr, tempChrData, true); } finally { try { if (inputBufferReader != null) { inputBufferReader.close(); } else if (inputFileReader != null) { inputFileReader.close(); } } catch (Exception ex) { log.warn(null, ex); } } return combinedPlot; }
From source file:adept.utilities.Grapher.java
/** * Make time vs size graph.//from w ww.ja va2s.c o m * * @param timevalues the timevalues * @param sizevalues the sizevalues * @param filename the filename * @param linelabel the linelabel * @param Xlabel the xlabel * @param Ylabel the ylabel * @param title the title */ public static void makeTimeVsSizeGraph(ArrayList<Double> timevalues, ArrayList<Double> sizevalues, File filename, String linelabel, String Xlabel, String Ylabel, String title) { try { XYSeriesCollection scatter_plot_dataset = new XYSeriesCollection(); XYSeries data = new XYSeries(linelabel); for (int i = 0; i < sizevalues.size(); i++) { data.add(sizevalues.get(i), timevalues.get(i)); } scatter_plot_dataset.addSeries(data); /* Step -2:Define the JFreeChart object to create line chart */ JFreeChart scatterPlotObject = ChartFactory.createScatterPlot(Ylabel, Xlabel, title, scatter_plot_dataset, PlotOrientation.VERTICAL, true, true, false); /* Step -3 : Write line chart to a file */ int width = 640; /* Width of the image */ int height = 480; /* Height of the image */ ChartUtilities.saveChartAsPNG(filename, scatterPlotObject, width, height); } catch (Exception e) { e.printStackTrace(); } }
From source file:net.sf.mzmine.chartbasics.gui.javafx.demo.FXChartGestureDemo.java
/** * Creates a dataset, consisting of two series of monthly data. * * @return the dataset.// w w w. jav a 2s . com */ private static XYDataset createDataset() { XYSeriesCollection data = new XYSeriesCollection(); Random r = new Random(System.currentTimeMillis()); for (int i = 0; i < 3; i++) { XYSeries s = new XYSeries("Series" + i); for (int x = 0; x < 100; x++) { double v = r.nextGaussian() * (i + 1); s.add(x, v); } data.addSeries(s); } return data; }
From source file:ChartPanelMaker.java
public static ChartPanel createChart(ArrayList<Voter> voters, ArrayList<Candidate> candidates, ArrayList<Candidate> committee, String title) { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries comitteeDataset = new XYSeries("Committee"); for (Candidate c : committee) { comitteeDataset.add(c.getX(), c.getY()); }//from w w w. ja v a 2s .c om dataset.addSeries(comitteeDataset); int n = voters.size(); int m = candidates.size(); int skipN = n / 150; if (skipN < 1) { skipN = 1; } int skipM = m / 150; if (skipM < 1) { skipM = 1; } Collections.sort(voters, Election.VoterNameComparator); Collections.sort(candidates, Election.CandidateNameComparator); XYSeries voterDataset = new XYSeries("Voters"); for (int i = 0; i < n; i++) { Voter v = voters.get(i); if (i % skipN == 0) { voterDataset.add(v.getX(), v.getY()); } } dataset.addSeries(voterDataset); XYSeries candidateDataset = new XYSeries("Candidates"); for (int i = 0; i < m; i++) { Candidate c = candidates.get(i); if (i % skipM == 0) { candidateDataset.add(c.getX(), c.getY()); } } dataset.addSeries(candidateDataset); Shape committeeShape = ShapeUtilities.createDiamond(5); Shape voterShape = ShapeUtilities.createDownTriangle(3); Shape candidateShape = ShapeUtilities.createUpTriangle(3); Color committeeColor = Color.DARK_GRAY; Color voterColor = Color.ORANGE; Color candidateColor = Color.LIGHT_GRAY; JFreeChart chart = ChartFactory.createScatterPlot(title, "", "", dataset, PlotOrientation.VERTICAL, true, true, true); XYPlot plot = chart.getXYPlot(); XYItemRenderer r = plot.getRenderer(); r.setSeriesShape(0, committeeShape); r.setSeriesPaint(0, committeeColor); r.setSeriesShape(1, voterShape); r.setSeriesPaint(1, voterColor); r.setSeriesShape(2, candidateShape); r.setSeriesPaint(2, candidateColor); ChartPanel chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:org.hxzon.demo.jfreechart.PolarChartDemo.java
private static XYDataset createDataset1() { boolean notify = false; XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series1 = new XYSeries(series1Name); //(theta,radius) series1.add(10, 2, notify);// w ww. j a va 2 s . c om series1.add(20, 4, notify); series1.add(30, 6, notify); dataset.addSeries(series1); return dataset; }
From source file:projects.hip.exec.HrDiagram.java
/** * Plot the HR diagram chart from the given data. * @param series/*www . j a v a 2s. c o m*/ * A {@link XYSeries} containing the HR diagram data. * @return * A {@link JFreeChart} containing the plot. */ private static JFreeChart getHrChart(XYSeries series) { XYSeriesCollection hrData = new XYSeriesCollection(); hrData.addSeries(series); // Set up the renderer XYLineAndShapeRenderer hrRenderer = new XYLineAndShapeRenderer(); hrRenderer.setSeriesLinesVisible(0, false); hrRenderer.setSeriesShapesVisible(0, true); hrRenderer.setSeriesShape(0, new Ellipse2D.Double(-0.5, -0.5, 1, 1)); // Configure axes NumberAxis xAxis = new NumberAxis("B - V [mag]"); xAxis.setRange(-0.5, 2.25); NumberAxis yAxis = new NumberAxis("H [mag]"); yAxis.setInverted(true); yAxis.setRange(-5, 13); // Configure plot XYPlot xyplot = new XYPlot(hrData, xAxis, yAxis, hrRenderer); xyplot.setBackgroundPaint(Color.white); JFreeChart hrChart = new JFreeChart("HR diagram of Hipparcos stars", xyplot); hrChart.removeLegend(); hrChart.setBackgroundPaint(Color.white); return hrChart; }