1 37 38 package org.jfree.chart.demo; 39 40 import org.jfree.chart.ChartFactory; 41 import org.jfree.chart.ChartPanel; 42 import org.jfree.chart.JFreeChart; 43 import org.jfree.chart.axis.NumberAxis; 44 import org.jfree.chart.plot.PlotOrientation; 45 import org.jfree.chart.plot.XYPlot; 46 import org.jfree.chart.renderer.XYDotRenderer; 47 import org.jfree.data.XYDataset; 48 import org.jfree.ui.ApplicationFrame; 49 import org.jfree.ui.RefineryUtilities; 50 51 56 public class ScatterPlotDemo4 extends ApplicationFrame { 57 58 63 public ScatterPlotDemo4(String title) { 64 65 super(title); 66 XYDataset data = new SampleXYDataset2(); 67 JFreeChart chart = ChartFactory.createScatterPlot( 68 "Scatter Plot Demo", 69 "X", 70 "Y", 71 data, 72 PlotOrientation.VERTICAL, 73 true, 74 true, 75 false 76 ); 77 XYPlot plot = chart.getXYPlot(); 78 plot.setRenderer(new XYDotRenderer()); 79 plot.setDomainCrosshairVisible(true); 80 plot.setRangeCrosshairVisible(true); 81 82 NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); 83 domainAxis.setAutoRangeIncludesZero(false); 84 85 ChartPanel chartPanel = new ChartPanel(chart); 86 chartPanel.setPreferredSize(new java.awt.Dimension (500, 270)); 87 setContentPane(chartPanel); 88 89 } 90 91 102 107 public static void main(String [] args) { 108 109 ScatterPlotDemo4 demo = new ScatterPlotDemo4("Scatter Plot Demo 4"); 110 demo.pack(); 111 RefineryUtilities.centerFrameOnScreen(demo); 112 demo.setVisible(true); 113 114 } 115 116 } 117 | Popular Tags |