Best way in Plotting lots of points

I have meshed a plate with 40000 point. Currently it is as following.
abc(ii)=plot(kkk(ii,1),kkk((ii+n_node/3),1),'.',...
'LineWidth',6,...
'MarkerEdgeColor',[1 1 1]*IDC(ii,1),...
'MarkerFaceColor',[1 1 1]*IDC(ii,1),...
'MarkerSize',6);
any idea that I can present results more nice?
I am thinking something like as gradient colors.

 Risposta accettata

Walter Roberson
Walter Roberson il 14 Giu 2015

0 voti

I think you should be considering using scatter() instead of plot(). plotting one point at a time is time-consuming when you have a lot of points.

5 Commenti

can you show a comparison photo (plot and scatter) You may want to bring a simple code here.
num_to_plot = 1000;
pointsize = 15;
x = kkk(1:num_to_plot,1);
y = kkk(n_node/3 + (1:num_to_plot),1);
pointcolor = IDC(1:num_to_plot,1) * [1 1 1]; %grayscale?
scatter(x, y, pointsize, pointcolor);
This will create one graphics object to display all of the points. The loop you were using would create one graphics object for each point to plot; managing all of those graphics objects gets slow.
The output probably will not look much different, but it will be much faster.
In order to give you ideas as to how your plot might look nicer, we would need to know something about the meaning of your data. Is IDC the "value" associated with the data? Have you considered using coloring by value, such as
num_to_plot = 1000;
pointsize = 15;
x = kkk(1:num_to_plot,1);
y = kkk(n_node/3 + (1:num_to_plot),1);
pointcolor = IDC(1:num_to_plot,1); %not grayscale
scatter(x, y, pointsize, pointcolor);
colormap(hot(128)); %activate pseudocolor map with 128 entries
This differs from your code because your code used IDC(ii,1) as a grayscale intensity; the above code maps the range of IDC values into the colormap. Note: if you want to be able to compare plots you might need
caxis([0 1]);
We would also need to know if there is a regular grid of data, or even a parametric grid of data that could be extracted from kkk.
No, I don't think I want to revise my answer. The first scatter() I gave is still valid, and the second about pseudocolor is still useful information about how you might improve the presentation of your plot.
It is possible that the pointsize I used is larger than you would prefer; you can change that.
Mean we still would also need to know if there is a regular grid of data, or even a parametric grid of data that could be extracted from kkk.
I am not sure about your question. but, there is a girding approach. The issue is by using scatter that gives single color to all points while in the original written code I have assigned a color to each point. I am going to use your suggestion and see what will be results.
scatter() does not give a single color to all points. Notice the pointcolor variable I create is an array of values, one row per point. For example try this experiment:
scatter(rand(1,10),rand(1,10),35,rand(10,1))
and observe that the different points have different colors.

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by