List of usage examples for org.jfree.chart ChartFactory createScatterPlot
public static JFreeChart createScatterPlot(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:edu.ucla.stat.SOCR.chart.demo.YIntervalChartDemo1.java
/** * Creates a new chart./*from ww w .j a va 2s . c o m*/ * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createScatterPlot(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, false); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new YIntervalRenderer()); setXSummary(dataset); return chart; }
From source file:org.matsim.core.utils.charts.XYScatterChart.java
private JFreeChart createChart(final String title, final String categoryAxisLabel, final String valueAxisLabel, final XYSeriesCollection dataset) { JFreeChart c = ChartFactory.createScatterPlot(title, categoryAxisLabel, valueAxisLabel, dataset, PlotOrientation.VERTICAL, true, // legend? false, // tooltips? false // URLs? );/* www. j av a 2s.c om*/ if (this.isLogarithmicAxis) { XYPlot p = (XYPlot) c.getPlot(); LogarithmicAxis axis_x = new LogarithmicAxis(this.xAxisLabel); LogarithmicAxis axis_y = new LogarithmicAxis(this.yAxisLabel); axis_x.setAllowNegativesFlag(false); axis_y.setAllowNegativesFlag(false); p.setDomainAxis(axis_x); p.setRangeAxis(axis_y); } return c; }
From source file:org.jfree.chart.demo.ChartTiming2.java
/** * Runs the test./*from w w w . j a v a 2s .c om*/ */ public void run() { this.finished = false; // create a dataset... final XYDataset data = new SampleXYDataset2(1, 1440); // create a scatter chart... final boolean withLegend = true; final JFreeChart chart = ChartFactory.createScatterPlot("Scatter plot timing", "X", "Y", data, PlotOrientation.VERTICAL, withLegend, false, false); final XYPlot plot = chart.getXYPlot(); plot.setRenderer(new XYDotRenderer()); final BufferedImage image = new BufferedImage(400, 300, BufferedImage.TYPE_INT_RGB); final Graphics2D g2 = image.createGraphics(); final Rectangle2D chartArea = new Rectangle2D.Double(0, 0, 400, 300); // set up the timer... final Timer timer = new Timer(10000, this); timer.setRepeats(false); int count = 0; timer.start(); while (!this.finished) { chart.draw(g2, chartArea, null, null); System.out.println("Charts drawn..." + count); if (!this.finished) { count++; } } System.out.println("DONE"); }
From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.ClinicalPlot.java
private void createChart() { //String xLabel = factor1.toString(); String xLabel = factor1AxisLabel; //String yLabel = factor2.toString(); String yLabel = factor2AxisLabel; clinicalChart = ChartFactory.createScatterPlot("Clinical Plot", xLabel, yLabel, null, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) clinicalChart.getPlot(); buildLegend();/*from ww w . j av a 2s .c o m*/ plot.setNoDataMessage(null); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setUseOutlinePaint(true); plot.setRangeCrosshairVisible(false); plot.setDomainCrosshairVisible(false); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); //should determine axis range using datapoints. domainAxis.setAutoRangeIncludesZero(false); //get domain and range of the axis. DataRange domainAxisLimits = getDataRange(dataPoints, factor1, true); DataRange rangeAxisLimits = getDataRange(dataPoints, factor2, true); //domainAxis.setRange(domainAxisLimits.getMinRange(), domainAxisLimits.getMaxRange()); //rangeAxis.setRange(rangeAxisLimits.getMinRange(), rangeAxisLimits.getMaxRange()); double domainMax = Math.max(100.0, domainAxisLimits.getMaxRange()) + 5.0; double rangeMax = Math.max(100.0, rangeAxisLimits.getMaxRange()) + 5.0; domainAxis.setRange(0.0, domainMax); rangeAxis.setRange(0.0, rangeMax); System.out.println("domainAxis=" + domainAxis.getLabel()); System.out.println("rangeAxis=" + rangeAxis.getLabel()); createGlyphsAndAddToPlot(plot); }
From source file:adams.gui.visualization.jfreechart.chart.ScatterPlot.java
/** * Performs the actual generation of the chart. * * @param data the data to use/*from w w w.j a va2 s .c om*/ * @return the chart */ @Override protected JFreeChart doGenerate(XYDataset data) { JFreeChart result = ChartFactory.createScatterPlot(m_Title, m_LabelX, m_LabelY, data, m_Orientation.getOrientation(), m_Legend, m_ToolTips, false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); if (result.getXYPlot().getSeriesCount() == 2) { renderer.setSeriesLinesVisible(0, false); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesShapesVisible(1, false); result.getXYPlot().setRenderer(renderer); } return result; }
From source file:org.owasp.benchmark.score.report.ScatterTools.java
private JFreeChart display(String title, int height, OverallResults or) { JFrame f = new JFrame(title); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series = new XYSeries("Scores"); int totalTools = 0; double totalToolTPR = 0; double totalToolFPR = 0; for (OverallResult r : or.getResults()) { series.add(r.falsePositiveRate * 100, r.truePositiveRate * 100); totalTools++;/*from ww w .j ava2 s . com*/ totalToolTPR += r.truePositiveRate; totalToolFPR += r.falsePositiveRate; } atpr = totalToolTPR / totalTools; afpr = totalToolFPR / totalTools; if (or.getResults().size() > 1) { series.add(afpr * 100, atpr * 100); } dataset.addSeries(series); chart = ChartFactory.createScatterPlot(title, "False Positive Rate", "True Positive Rate", dataset, PlotOrientation.VERTICAL, true, true, false); theme.apply(chart); XYPlot xyplot = chart.getXYPlot(); initializePlot(xyplot); makeDataLabels(or, xyplot); makeLegend(or, 103, 93, dataset, xyplot); XYTextAnnotation time = new XYTextAnnotation("Tool run time: " + or.getTime(), 12, -5.6); time.setTextAnchor(TextAnchor.TOP_LEFT); time.setFont(theme.getRegularFont()); time.setPaint(Color.red); xyplot.addAnnotation(time); ChartPanel cp = new ChartPanel(chart, height, height, 400, 400, 1200, 1200, false, false, false, false, false, false); f.add(cp); f.pack(); f.setLocationRelativeTo(null); // f.setVisible(true); return chart; }
From source file:org.simbrain.plot.rasterchart.RasterPlotPanel.java
/** * Initialize Chart Panel./* w w w . j ava 2 s .com*/ */ public void init() { // Generate the graph chart = ChartFactory.createScatterPlot("", // Title "Iterations", // x-axis Label "Value(s)", // y-axis Label model.getDataset(), // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); XYItemRenderer renderer = ((XYPlot) chart.getPlot()).getRenderer(); renderer.setSeriesPaint(0, Color.BLACK); double size = 1.0; double delta = size / 2.0; Shape shape1 = new Rectangle2D.Double(-delta, -delta, size, size); Shape shape2 = new Ellipse2D.Double(-delta, -delta, size, size); renderer.setSeriesShape(0, shape1); renderer.setSeriesShape(1, shape2); renderer.setSeriesShape(2, shape1); renderer.setSeriesShape(3, shape2); chartPanel.setChart(chart); chart.setBackgroundPaint(null); // Create chart settings listener model.addChartSettingsListener(new ChartSettingsListener() { public void chartSettingsUpdated() { // Handle range properties chart.getXYPlot().getRangeAxis().setAutoRange(model.isAutoRange()); if (!model.isAutoRange()) { chart.getXYPlot().getRangeAxis().setRange(model.getRangeLowerBound(), model.getRangeUpperBound()); } // Handle domain properties if (model.isFixedWidth()) { chart.getXYPlot().getDomainAxis().setFixedAutoRange(model.getWindowSize()); } else { chart.getXYPlot().getDomainAxis().setFixedAutoRange(-1); chart.getXYPlot().getDomainAxis().setAutoRange(true); } } }); // Invoke an initial event in order to set default settings model.fireSettingsChanged(); }
From source file:org.jfree.chart.demo.YIntervalChartDemo.java
/** * Creates a new chart./*from w w w . ja v a2s. c om*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final IntervalXYDataset dataset) { final JFreeChart chart = ChartFactory.createScatterPlot("Y Interval Chart Demo", // chart title "X", // domain axis label "Y", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot plot = chart.getXYPlot(); plot.setRenderer(new YIntervalRenderer()); return chart; }
From source file:view.visualization.TXTVisualization.java
public static void drawChart(String a, String b, String txt) { String[] boje = null;//from www . j a v a 2s .co m LinkedList<String> atributi = new LinkedList<String>(); LinkedList<String> sviAtributi = new LinkedList<String>(); String[] vrAtribut = null; XYSeries[] xy = null; XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); int brojac = 0; boolean kraj = false; LinkedList<Integer> numeric = new LinkedList<Integer>(); try { BufferedReader in = new BufferedReader(new FileReader(txt)); int br = Integer.parseInt(in.readLine().split(" ")[1]); for (int j = 0; j < br + 1; j++) { String pom = in.readLine(); if (pom.contains("@attribute")) { if (pom.contains("numeric")) { sviAtributi.add(pom.substring(11, pom.lastIndexOf("n") - 1)); } else { sviAtributi.add(pom.split(" ")[1]); } } if (pom.contains("@attribute") && pom.contains("numeric")) { atributi.add(pom.substring(11, pom.lastIndexOf("n") - 1)); } if (!pom.contains("numeric")) { brojac++; numeric.add(j - 2); } } String s = in.readLine(); boje = s.substring(s.indexOf("{") + 1, s.lastIndexOf("}")).split(","); xy = new XYSeries[boje.length]; for (int i = 0; i < boje.length; i++) { xy[i] = new XYSeries(boje[i]); } while (!kraj) { String pom2 = in.readLine(); if (!(pom2.contains("@data"))) { vrAtribut = pom2.split(","); for (int i = 0; i < xy.length; i++) { if (xy[i].getKey().equals(vrAtribut[vrAtribut.length - 1])) { xy[i].add(Double.parseDouble(vrAtribut[sviAtributi.indexOf(a)]), Double.parseDouble(vrAtribut[sviAtributi.indexOf(b)])); } } } } in.close(); } catch (Exception e) { e.getMessage(); } for (int i = 0; i < xy.length; i++) { xySeriesCollection.addSeries(xy[i]); } JFreeChart grafik = ChartFactory.createScatterPlot("Vizuelizacija", a, b, xySeriesCollection, PlotOrientation.VERTICAL, true, true, false); ChartFrame proba = new ChartFrame("DataMiner", grafik); proba.setVisible(true); proba.setSize(500, 600); }
From source file:org.pf.midea.MainUI.java
private void showConstellationWindow(ConstellationPoint[] _map, String _name) { JFrame constellation = new JFrame(" ?? " + _name); constellation.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); XYSeriesCollection dots = new XYSeriesCollection(); XYSeries series = new XYSeries(_name); JFreeChart chart = ChartFactory.createScatterPlot("", "I", "Q", dots, PlotOrientation.VERTICAL, false, false, false);/*from w w w. j av a 2s. com*/ XYPlot xyPlot = chart.getXYPlot(); CustomXYToolTipGenerator tooltipsGenerator = new CustomXYToolTipGenerator(); ArrayList<String> tooltips = new ArrayList<>(); for (ConstellationPoint ccp : _map) { double I = ccp.getI(); double Q = ccp.getQ(); series.add(I, Q); tooltips.add(ccp.getCode().getStringSequence()); } tooltipsGenerator.addToolTipSeries(tooltips); xyPlot.getRenderer().setBaseToolTipGenerator(tooltipsGenerator); double maxX = StatisticsTools.round(Math.abs(series.getMaxX()), 3); double maxY = StatisticsTools.round(Math.abs(series.getMaxY()), 3); double minX = StatisticsTools.round(Math.abs(series.getMinX()), 3); double minY = StatisticsTools.round(Math.abs(series.getMinY()), 3); if (maxX != 0 || minX != 0) { double X = Math.max(minX, maxX); xyPlot.getDomainAxis().setRange(-1.1 * X, 1.1 * X); } else xyPlot.getDomainAxis().setRange(-1, 1); if (maxY != 0 || minY != 0) { double Y = Math.max(minY, maxY); xyPlot.getRangeAxis().setRange(-1.1 * Y, 1.1 * Y); } else xyPlot.getRangeAxis().setRange(-1, 1); dots.addSeries(series); xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.setDomainGridlinePaint(Color.GRAY); xyPlot.setRangeGridlinePaint(Color.GRAY); xyPlot.getRenderer().setSeriesPaint(0, Color.BLACK); xyPlot.setDomainZeroBaselineVisible(true); xyPlot.setRangeZeroBaselineVisible(true); ChartPanel chartPanel = new ChartPanel(chart); JPanel nestedPanel = new JPanel(); nestedPanel.add(chartPanel, new CellConstraints()); constellation.add(nestedPanel); constellation.pack(); constellation.setLocationRelativeTo(null); constellation.setResizable(false); constellation.setVisible(true); }