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:org.jfree.chart.demo.ImageMapDemo7.java
/** * Starting point for the demo.// ww w . ja va 2 s . co m * * @param args ignored. */ public static void main(final String[] args) { final XYDataset data = new SampleXYDataset2(); final JFreeChart chart = ChartFactory.createScatterPlot("Scatter Plot Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); // final Legend legend = chart.getLegend(); // if (legend instanceof StandardLegend) { // final StandardLegend sl = (StandardLegend) legend; // sl.setDisplaySeriesShapes(true); //} final NumberAxis domainAxis = (NumberAxis) chart.getXYPlot().getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); chart.setBackgroundPaint(java.awt.Color.white); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("scatter100.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("scatter100.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"scatter100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } }
From source file:org.jfree.chart.demo.DefaultXYDatasetDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { return ChartFactory.createScatterPlot("DefaultXYDatasetDemo1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, false, false); }
From source file:org.jfree.chart.demo.GridBandDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("Grid Band Demo 1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, false, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setNoDataMessage("NO DATA"); xyplot.setRangeZeroBaselineVisible(true); xyplot.setDomainTickBandPaint(new Color(0, 100, 0, 50)); xyplot.setRangeTickBandPaint(new Color(0, 100, 0, 50)); return jfreechart; }
From source file:org.jfree.chart.demo.LogAxisDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("Log Axis Demo 1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); LogAxis logaxis = new LogAxis("X"); LogAxis logaxis1 = new LogAxis("Y"); xyplot.setDomainAxis(logaxis);/*w ww . ja v a 2 s . com*/ xyplot.setRangeAxis(logaxis1); return jfreechart; }
From source file:org.jfree.chart.demo.LogarithmicAxisDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("Logarithmic Axis Demo 1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); LogarithmicAxis logarithmicaxis = new LogarithmicAxis("X"); LogarithmicAxis logarithmicaxis1 = new LogarithmicAxis("Y"); xyplot.setDomainAxis(logarithmicaxis); xyplot.setRangeAxis(logarithmicaxis1); return jfreechart; }
From source file:org.jfree.chart.demo.LogarithmicAxisDemo2.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("Logarithmic Axis Demo 2", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); LogarithmicAxis logarithmicaxis = new LogarithmicAxis("X"); logarithmicaxis.setExpTickLabelsFlag(true); logarithmicaxis.setStrictValuesFlag(false); LogarithmicAxis logarithmicaxis1 = new LogarithmicAxis("Y"); logarithmicaxis1.setAllowNegativesFlag(true); logarithmicaxis1.setLog10TickLabelsFlag(true); xyplot.setDomainAxis(logarithmicaxis); xyplot.setRangeAxis(logarithmicaxis1); return jfreechart; }
From source file:LisajousApp.Draw.java
private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createScatterPlot("Lissajous", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false);/* w w w . j ava 2s . co m*/ chart.setBackgroundPaint(Color.lightGray); XYPlot plot = (XYPlot) chart.getPlot(); plot.getRenderer().setSeriesPaint(0, Color.blue); // ta linia niej odpowiada za grubo punktw Shape shape = new Ellipse2D.Double(0, 0, 0.5, 0.5); plot.getRenderer().setSeriesShape(0, shape); return chart; }
From source file:org.jfree.chart.demo.ScatterPlotDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter Plot Demo 1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, false, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setNoDataMessage("NO DATA"); xyplot.setDomainZeroBaselineVisible(true); xyplot.setRangeZeroBaselineVisible(true); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setSeriesOutlinePaint(0, Color.black); xylineandshaperenderer.setUseOutlinePaint(true); NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setTickMarkInsideLength(2.0F); numberaxis.setTickMarkOutsideLength(0.0F); NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis(); numberaxis1.setTickMarkInsideLength(2.0F); numberaxis1.setTickMarkOutsideLength(0.0F); return jfreechart; }
From source file:org.jfree.chart.demo.YIntervalChartDemo1.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("Y Interval Chart Demo", "X", "Y", intervalxydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); xyplot.setRenderer(new YIntervalRenderer()); return jfreechart; }
From source file:iad_zad3.gui.Charts.java
public static JFreeChart getKmeansChart(final List<double[]> data, final List<double[]> centroids) { JFreeChart jfreechart = ChartFactory.createScatterPlot("", "x", "y", createDataset(data, centroids), PlotOrientation.VERTICAL, false, false, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesShape(1, circleSmall); renderer.setSeriesPaint(1, Color.RED); renderer.setSeriesShape(0, circleBig); renderer.setSeriesPaint(0, Color.BLUE); ValueAxis domainAxis = xyPlot.getDomainAxis(); domainAxis.setRange(DataStats.minVal[0] * 1.2, DataStats.maxVal[0] * 1.2); ValueAxis rangeAxis = xyPlot.getRangeAxis(); rangeAxis.setRange(DataStats.minVal[1] * 1.2, DataStats.maxVal[1] * 1.2); jfreechart.setBackgroundPaint(Color.WHITE); return jfreechart; }