Java: a really simple scatter utility

I know that there are many comparisons of java graphics libraries, but I do not find what I need. I just need an easy-to-use toolkit that creates diffusion images from a set of coordinates. There is no graphical interface, no interaction, no fancy display, just a basic XY coordinate system with points.

There would be no end of the world to use something that offers much more functionality than I need, but I would prefer. Do you know something like what I'm looking for?

+6
java charts scatter-plot
source share
4 answers

Have you looked at JFreeChart ? Although he can do very complex things, he also does simple things. Below is a screenshot of the possibility of scattering.

alt text
(source: jfree.org )

+7
source share

I looked back at what existed and realized that jcckit is technically very good, but just lacking a simple wrapper around it to make it easier 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 scatterplots, you can freely add lines to the same axes if you want to use addPlot and plot.

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

+3
source share

You use a custom JPanel to draw your data (not tested, but you get the idea ...)

 private List<Point2D> data=(...); JPanel pane=new JPanel() { protected paintComponent(Graphics2D g) { super.paintComponent(g); int minx=(...),miny=(...),maxx=(...),maxy=(...); for(Point2D p: data) { int x=((p.getX()-minx)/(maxx-minx))*this.getWidth(); int y=((p.getY()-miny)/(maxy-miny))*this.getHeight(); g.drawLine(x-5,y,x+5,y); g.drawLine(x,y-5,x,y+5); } } pane.setOpaque(true); (...) anotherComponent.add(pane); (...) } 
+2
source share

You can also check Simple Java graph . Minimal example (without parameters):

 Plot plot = Plot.plot(null). // setting data series(null, Plot.data(). xy(1, 2). xy(3, 4), null); // saving sample_minimal.png plot.save("sample_minimal", "png"); 
+1
source share

All Articles