Question about plotting a long series of lines
5 views (last 30 days)
Hello, thanks for reading this,
I want to plot a series of lines, which can range from 10 or so lines to thousands.
The total network is a binary tree, but not every line bifurcates. What I do at the moment is use a for loop, and plot every line separately, but that can take a large amount of time, and it doesn't help when I need to replot the tree in repetition. I was wondering, is there an easy way to vectorize this?
My data is the following: I have a point matrix (a N by 3 matrix, where I have n points, with columns x y and z coordinates), and a face matrix (a M by 2 matrix, where I have M faces, with point indexes 1 and 2). An example can be the following:
pointMx = [0 0 0; 0 5 0; 0 10 5; 0 10 0];
faceMx = [1 4; 4 2; 4 3];
So I have a total of three lines, with one bifurcating into two segments. I can plot this by looping over the number of rows in faceMx and plotting each line individually, but that can take time. Is there a way to vectorize the plotting of these lines?
Thanks for your help!
Doug Hull on 12 Nov 2013
>> clf; tic; for i = 1:10000; h(i) = line(rand(1,2), rand(1,2)); end; toc Elapsed time is 0.933154 seconds.
I respect the idea of limiting your overhead by reducing the number of line objects created. However, 0.9 second to make this graph. Is it really worth your effort to make this more efficient?