Connect points in scatter plot by lines

691 views
Skip to first unread message

Andreas Burger

unread,
Aug 13, 2013, 3:07:08 AM8/13/13
to jz...@googlegroups.com
Hi all,

is it possible to connect points in a Jzy3d scatter plot by lines?
If so, please could someone give me a short example?

Best regards, Andreas

Martin Pernollet

unread,
Aug 13, 2013, 3:52:51 AM8/13/13
to Jzy3d
Andreas,
I see two ways:
1) using the existing LineStrip & Scatter (or MultiColorScatter*) objects. Although being distinct objects, they can look like a single object and might have the advantage to also be drawn separately.
2) looking at the implementation of these two classes, and implement your ConnectedScatter based on the Open GL primitives
Cheers,
Martin


--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes Jzy3d.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse jzy3d+un...@googlegroups.com.
Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .
 
 

Andreas Burger

unread,
Aug 13, 2013, 5:18:49 AM8/13/13
to jz...@googlegroups.com
Thank you. Your first way works fine.

Regards, Andreas


2013/8/13 Martin Pernollet <martin.p...@gmail.com>

--
Vous recevez ce message car vous êtes abonné à un sujet dans le groupe Google Groupes "Jzy3d".
Pour vous désabonner de ce sujet, visitez le site https://groups.google.com/d/topic/jzy3d/kN8-a2W1laY/unsubscribe.
Pour vous désabonner de ce groupe et de tous ses sujets, envoyez un e-mail à l'adresse jzy3d+un...@googlegroups.com.

Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .
 
 



--
--
Andreas Burger
Wendtstr. 13
76185 Karlsruhe

kx1...@gmail.com

unread,
Oct 16, 2013, 11:12:24 PM10/16/13
to jz...@googlegroups.com
Hey Andreas,
 
I have a problem in  Iterator part. It might be a stupid problem.;(
 
Sorry about this.
 
The code is as follow:

 

public class Drawing extends AbstractDemo{

public static void main(String[] args) throws Exception {

DemoLauncher.openDemo(new Drawing());

}

public Drawing(){

}

public void init(){

//int size = 500000;

int size = 10;

float x;

float y;

float z;

LineStrip ls = new LineStrip();

//List<Coord3d> ls =new ArrayList<Coord3d>();

Coord3d[] points = new Coord3d[size];

// Create scatter points

for(int i=0; i<size; i++){

x = (float)Math.random() - 0.5f;

y = (float)Math.random() - 0.5f;

z = (float)Math.random() - 0.5f;

points[i] = new Coord3d(x, y, z);

Point lscolor = new Point(points[i], Color.RED);

ls.add(lscolor);

}

// Create a drawable scatter with a colormap

Scatter scatter = new Scatter(points, Color.YELLOW);

scatter.setWidth(7f);

// Create a chart and add scatter

Chart chart = new Chart();

chart.getAxeLayout().setMainColor(Color.WHITE);

chart.getView().setBackgroundColor(Color.BLACK);

chart.getScene().add(scatter);

ChartLauncher.openChart(chart);

chart.setAxeDisplayed(true);

chart.setViewMode(ViewPositionMode.FREE);

Iterator<LineStrip> lsIterator = this.lineStrips.iterator();

while (lsIterator.hasNext()) {

chart.getScene().getGraph().add(lsIterator.next());

}

}

}

 

If I define the line like

List<Coord3d> ls =new ArrayList<Coord3d>();

It can not use ls.add to add the point.

But it can use Iterator.

 

But if I define like

LineStrip ls = new LineStrip();

It can not use the Iterator.

 

Could you please tell me how to handle it, please?

I really appreciate it.

 

Best,

Nina


在 2013年8月13日星期二UTC-4上午5时18分49秒,Andreas Burger写道:

Andreas Burger

unread,
Oct 17, 2013, 1:55:36 AM10/17/13
to jz...@googlegroups.com
Hi Nina,

the iterator part in my code was only to add linestrips for more than one point programatically.
So here a small example to draw a linestrip between two points.


LineStrip ls = new LineStrip();
// add source point for the linestrip
ls.add(new Point(COORD3D Point, Color.BLACK));
// add target point for the linestrip
ls.add(new Point(COORD3D Point, Color.BLACK));
// display flag for linestrip
ls.setDisplayed(true);
// add linestrip ls to a list of linestrips
this.lineStrips.add(ls);

After doing that for every two points you want connect by a linestrip, you can use an iterator to add them to your scatter diagram.

Iterator<LineStrip> lsIterator = this.lineStrips.iterator();
        while (lsIterator.hasNext()) {
            chart.getScene().getGraph().add(lsIterator.next());
        }
        ChartLauncher.openChart(chart, NAME);

Regards,

Andreas


2013/10/17 <kx1...@gmail.com>

kx1...@gmail.com

unread,
Oct 18, 2013, 4:36:39 PM10/18/13
to jz...@googlegroups.com
Hey Andreas,

Thanks so much!
I've done.;)

Best,
Nina

Anas Ayad

unread,
Apr 21, 2017, 4:56:10 PM4/21/17
to Jzy3d
It worked for me too, I just wanted to say thanks for sharing.

Have a good day.
Reply all
Reply to author
Forward
0 new messages