Speed up plotting of multiple lines
Show older comments
Dear All Community members,
I have a question concerning speeding up the function plot.
I want to plot several (72835) lines in order to create a hexagonal pattern, where each line will be colored depending on its value represented in a third vector.
The coordinates of the lines are given in two matrices, ‘x’ and ‘y’, while the color depends on the matrix ‘yo’. These matrices are attached.
Example: Line 1
X-coordinates are given in x11 and x12 in matrix 'x'.
Y-coordinates are given in y11 and y21 in matrix 'y'.
The line has a blue-violet color palette. See Figure below.

The code I am using is given below, in addition to a plot of all the lines colored.
figure
for i=1:size(x,2)
plot(x(:,i), y(:,i), 'LineWidth', 2.5, 'Color', yo(i,:))
axis square ;
hold on
end
hold off
colormap(map)
colorbar('Position', [0.8 0.25 0.04 0.6]);
caxis([11 334])

It is very time-consuming to run, and the plot is really slow to respond if I want to zoom or etc.
Is it possible to plot this differently? E.g., Using a patch objective?
Any help is deeply appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!