Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: Really simple scatter plot utility

I know there are many comparisons of java plotting libraries out there, but I'm not finding what I need. I just want a mind-numbingly simple toolkit that creates images of scatterplots from a set of coordinates. No GUI, no interaction, no fancy display, just a basic XY coordinate system with points.

It wouldn't be the end of the world to use something that offers a lot more functionality than I need, but I'd rather not. Do you know of anything like what I'm looking for?

like image 418
Nick Heiner Avatar asked Dec 06 '09 23:12

Nick Heiner


People also ask

How scatter plot is useful in real world?

Scatter plots' primary uses are to observe and show relationships between two numeric variables. The dots in a scatter plot not only report the values of individual data points, but also patterns when the data are taken as a whole. Identification of correlational relationships are common with scatter plots.

What is better than a scatter plot?

Here's the difference. A Scatter Plot can help you display the relationship between key variables in your data. The nature of the relationship varies depending on the distribution of dots. Conversely, Line Charts are best-suited in displaying trends and patterns of variables in data.


2 Answers

Have you looked at JFreeChart? While it can do some very advanced things, it also does the simple as well. Shown below is a screenshot of its scatter plot capability.

alt text
(source: jfree.org)

like image 189
JasCav Avatar answered Sep 20 '22 06:09

JasCav


I looked around at what existed, and realized that jcckit is technically pretty good, but just lacks a simple wrapper around it to make it easy to use.

So I forked it and made a really simple wrapper. Here's how to use:

import static easyjcckit.QuickPlot.*;

double[] xaxis = new double[]{0,1,2,3,4,5};
double[] yvalues = new double[]{0,1,4,9,16,25};
scatter( xaxis, yvalues ); // create a plot using xaxis and yvalues
double[] yvalues2 = new double[]{0,1,2,3,4,5};
addScatter( xaxis, yvalues2 ); // create a second plot on top of first

System.out.println("Press enter to exit");
System.in.read();

As well as scatter plots, you can freely add lines to the same axes if you wish using 'addPlot' and 'plot'.

Here is the code: https://bitbucket.org/hughperkins/easyjcckit

like image 27
Hugh Perkins Avatar answered Sep 20 '22 06:09

Hugh Perkins