0

All I need is a function plot in 3D with some points on the surface. How can I achieve it?

At first I tried jzy3d but it turned out it's too much effort for such a basic task (especially because jzy3d lacks code samples and dependencies with JOGL may be cumbersome). So I tried Java Surface Plot and for the function surface part - it's perfect. But is it possible to add (x, y, z) points..? I guess not. In this case what other library could I use?

I know this question might feel off-topic, but such a simple plotting is a basic functionality and this answer is already 2 years old, so.. maybe there's something better now?

3 Answers 3

3

Orson Charts is a new (proprietary) library that will draw surface charts with no JOGL dependency (it contains a software renderer based on Java2D so there are no dependencies except the standard Java runtime). The surface renderer takes samples from a function y = f(x, z), so there might be an issue with your requirement where you say:

But is it possible to add (x, y, z) points..?

However, it would not be difficult to adapt the code to work with such data, so if Orson Charts looks like something you could use then please contact me.

1
  • Hello David, I would like to be able to derive a surface from a mesh of x, y, z points instead of being required to provide a continuous function. However, another thing I would like to be able to do (and what I think the OP is getting at) is having two "series" in the same 3D chart- a surface with other (possibly unlrelated) x, y, z scatter points rendered simultaneously. Does Orson support that? thank you!
    – J. Dimeo
    Jan 30, 2015 at 18:55
2

I'm quite new to stackoverflow, so maybe I'm bringing in some new (ore maybe old) view into this.

You can transform your 3D-points into 2D-Point, I'll submit a code snippet to it in ONE way (but there are many)

//point a (3D)
double ax = 3;
double ay = 4;
double az = 3;

//point b (2D)
double bx = 0;
double by = 0;

//assumtions
double cx = 0; //offset
double cz = 0; //offset

double scalex = 0.5;
double scalez = 0.5;

//trafo 3D -> 2D
bx = scalex * ax + cz;
by = scalez * az + cz;

I'm referring to http://en.wikipedia.org/wiki/3D_projection

do this with ALL your points and you'll see the graph plotted.

4
  • I don't want to project 3D points. I want to have fully three-dimensional plot with function surface AND additionally some points marked on it. In 3D as well.
    – alex
    Dec 24, 2013 at 11:04
  • i'm not sure how you you want to display (plot) 3D points on a 2D device (screen)... but if you adjust the parameters cx/cz and scalex/scaley you can rotate, zoom, shift(pan) on your [projected] plot Dec 24, 2013 at 12:05
  • Oh, that's what you mean. Projecting points is doable, but implementing a surface plot (goo.gl/CteZjO) which can move/rotate from scratch is way too much work. I'm sure there are libraries that take care of it.
    – alex
    Dec 24, 2013 at 12:48
  • oh i see - you're looking for a library ^^ - sorry, i don't know one, but maybe it IS worth programming one ^^ Dec 24, 2013 at 15:01
2

There are Jzy3d examples on Github showing how to draw surface and scatter plots.

You'll see that maven configuration is quite simple as you should simply declare a dependency to jzy3d (JOGL being transitively imported) :

<dependencies>
    <dependency>
        <groupId>org.jzy3d</groupId>
        <artifactId>jzy3d-api</artifactId>
        <version>0.9.2-SNAPSHOT</version>
    </dependency>
</dependencies>

You only have to declare Jzy3d's repository as follow

<repositories>
  <repository>
     <id>jzy3d-snapshots</id>
     <name>Jzy3d Snapshots</name>
     <url>http://maven.jzy3d.org/snapshots</url>
  </repository>
  <repository>
     <id>jzy3d-releases</id>
     <name>Jzy3d Releases</name>
     <url>http://maven.jzy3d.org/releases</url>
  </repository>

If the given example are not enough, you might also have a look at the developer guide.

Not the answer you're looking for? Browse other questions tagged or ask your own question.