How to plot a very large number of individual points
Show older comments
I have several vectors (240) each of different length.
Now for each entry of any vector I wish to plot:
1) A filled 'o' if the entry is 1
2) An empty(very lightly shaded) 'o' if the entry is 0
3) A 'x' if the entry is 2
To achieve this I have a nested for loop structure. The outer loop traverses through the vectors, and the inner loop traverses through the entries of each particular vector. Inside I have an if else block that achieves the above plotting.
The code for this is as follows:
figure_counter = figure_counter + 1;
figure(figure_counter);
hold on
% Set a max y value to start plotting
y_val = length(window_size_list);
for k = 1: length(window_size_list)
y_val = y_val - 1;
t_val = time_EWS{k};
for j = 1: length(H{k})
if H{k}(j) == 1
H_val = 1;
plot(t_val(j), y_val, 'LineStyle', 'none', 'LineWidth', 1, 'Marker', 'o', 'MarkerSize', 5, 'MarkerFaceColor', PS.Grey4, 'MarkerEdgeColor' , PS.Grey5);
elseif H{k}(j) == 2
plot(t_val(j), y_val, 'LineStyle', 'none', 'LineWidth', 1, 'Marker', 'x', 'MarkerSize', 5, 'MarkerFaceColor', PS.Red1, 'MarkerEdgeColor' , PS.Red2)
else
H_val = 0;
plot(t_val(j), y_val, 'LineStyle', 'none', 'LineWidth', 1, 'Marker', 'o', 'MarkerSize', 5, 'MarkerFaceColor', PS.Grey1, 'MarkerEdgeColor' , PS.Grey2);
end
end
end
xlabel('t');
ylabel('count');
The Problem:
The figure is very slow to respond. I am not able to set any figure properties as the property inspector just keeps loading.
What can I do to fix this issue? Am I using the wrong function to plot?
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Object Properties 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!