Simple XY Plot

  • Follow


Though I've done the usual "web search" and found jFreeChart, jCharts,
and PlotPackage, I thought I'd post here in case I've missed any
options for a simple, free two axis XY plotting package/class.

jFreeChart is overkill ... the other two look like possibilities.

Of course, I can just use AWT's Graphics or Graphics3d class, but am
hoping to find a slighter higher-level implementation.

Thanks for your ideas!

-- 
Prof Kenneth H Jacker       khj@cs.appstate.edu
Computer Science Dept       www.cs.appstate.edu/~khj
Appalachian State Univ
Boone, NC  28608  USA        

0
Reply Kenneth 3/28/2005 2:51:22 PM

Kenneth Jacker wrote:
> Though I've done the usual "web search" and found jFreeChart, jCharts,
> and PlotPackage, I thought I'd post here in case I've missed any
> options for a simple, free two axis XY plotting package/class.
> 
> jFreeChart is overkill ... 

JFreeChart is a big library, but we work hard to make it use sensible 
defaults so that you don't have to write a lot of code to get great 
looking charts.  For example, here is a scatter plot demo written using 
the JFreeChart API:

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;

public class ScatterPlotDemo extends ApplicationFrame {

     public ScatterPlotDemo(String title) {

         super(title);

         XYSeriesCollection dataset = new XYSeriesCollection();

         XYSeries series1 = new XYSeries("Series 1");
         series1.add(1.0, 4.5);
         series1.add(4.4, 3.2);
         dataset.addSeries(series1);

         XYSeries series2 = new XYSeries("Series 2");
         series2.add(3.2, 8.5);
         series2.add(4.9, 3.7);
         dataset.addSeries(series2);

         JFreeChart chart = ChartFactory.createScatterPlot(
             "Scatter Plot Demo",  // title
             "X", "Y",             // axis labels
             dataset,              // dataset
             PlotOrientation.VERTICAL,
             true,                 // legend? yes
             true,                 // tooltips? yes
             false                 // URLs? no
         );
         ChartPanel chartPanel = new ChartPanel(chart);
         chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
         setContentPane(chartPanel);

     }

     public static void main(String[] args) {
         ScatterPlotDemo demo = new ScatterPlotDemo("Scatter Plot Demo");
         demo.pack();
         RefineryUtilities.centerFrameOnScreen(demo);
         demo.setVisible(true);
     }

}

I hope you'll give JFreeChart a try!

Regards,

Dave Gilbert
JFreeChart Project Leader
0
Reply David 3/28/2005 9:45:43 PM


Kenneth Jacker wrote:
> Of course, I can just use AWT's Graphics or Graphics3d class, but am
> hoping to find a slighter higher-level implementation.

Pipe the data into good olf gnuplot if you can live with an non all-Java 
  solution and a separate application.

/Thomas


-- 
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
0
Reply Thomas 3/29/2005 7:11:39 AM

2 Replies
343 Views

(page loaded in 0.36 seconds)

Similiar Articles:













7/25/2012 11:30:42 PM


Reply: