ScatterPlotDemo

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
luis_esru
Posts: 42
Joined: Tue Jan 20, 2004 6:40 pm
Location: Glasgow
Contact:

ScatterPlotDemo

Post by luis_esru » Wed Oct 13, 2004 7:51 am

David

How do I include more series in ScatterPlotDemo.java (1 point per series) without using SampleXYDataset2.java? See code below:

------------------------------------
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.Legend;
import org.jfree.chart.StandardLegend;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.XYDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;


import org.jfree.data.XYSeries;
import org.jfree.data.XYSeriesCollection;


/**
* A demo scatter plot.
*
* @author David Gilbert
*/
public class ScatterPlotDemo extends ApplicationFrame {

/**
* A demonstration application showing a scatter plot.
*
* @param title the frame title.
*/
public ScatterPlotDemo(String title) {

super(title);

//size and location
setLocation(300,100);
setSize (400,300);

//XYDataset data = new SampleXYDataset2();
XYSeries series = new XYSeries("Version1");
series.add(58.99,25.56);
XYDataset data = new XYSeriesCollection(series);

JFreeChart chart = ChartFactory.createScatterPlot(
"Scatter Plot Demo",
"X", "Y",
data,
PlotOrientation.VERTICAL,
true,
true,
false
);
Legend legend = chart.getLegend();
if (legend instanceof StandardLegend) {
StandardLegend sl = (StandardLegend) legend;
sl.setDisplaySeriesShapes(true);
}
NumberAxis domainAxis = (NumberAxis) chart.getXYPlot().getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
chartPanel.setVerticalAxisTrace(true);
chartPanel.setHorizontalAxisTrace(true);
chartPanel.setVerticalZoom(true);
chartPanel.setHorizontalZoom(true);
setContentPane(chartPanel);

}

// ****************************************************************************
// * 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. * *
// ****************************************************************************

/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
}
------------------------------------

Rgds,
Luis
University of Strathclyde in Glasgow
ESRU
luis@esru.strath.ac.uk

Locked