I have an array of X/Y data of length N, and a corresponding color array that is Nx3. I am hoping to color the plot of the X/Y data based on the corresponding color in the color array.
A single XY array is >100000 in size and I have lots of the arrays to plot so hoping to find a fast solution for this.
An example of how I am currently doing it in a loop
xy_data = zeros(100000, 2);
colors = zeros(100000, 3);
figure;
hold on
for i = 1:length(xy_data)
plot(xy_data(i, 1), xy_data(i, 2), '.', 'color', colors(i, :));
end
This technically works but it can be quite slow, especially when there are lots of data points, and lots of xy arrays to plot. I am wondering if
- is there a faster way?
- Is there a way to plot it as a multi color line, and not markers ('.')
