![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/410485/image.png)
fast plotting of matrix of unconnected data points (no lines) with reduced opacity
3 次查看(过去 30 天)
显示 更早的评论
I have a M x N matrix of datapoints, where M is large. I want to plot each row this matrix on the same plot using hold on. I want the opacity (alpha value) on each row plotted to be small so that the color intensity builds up in regions of many data points laid on top of one another. the 'plot' function can be used to plot matrices relatively quickly, but unfortunately, i can only acheive an alpha value of less than 1 if i plot lines. Howver, I don't want to join points up as line, I want to plot unconnected individual points, as circles for example. When I use a marker like 'o', the alpha value is ignored as far I can tell when using the plot function. An alternative is to use scatter, which allows unconnected individual data points to have an alpha of less than 1. However, scatter can't be used with matrices of data. Hence, I have to have a for loop and use scatter on each row sequentially, which is very slow.
Is there a quick way to do what I am trying to do?
(edit: I think plot actually plots each column of a matrix, but you get the problem, hopefully)
Thanks in advance
0 个评论
回答(1 个)
Pranav Verma
2020-11-11
Hi James,
You can use scatter plot with the matrix of data by using the plotmatrix function where in the function creates multiple subplots for matrix data but in this case since you require all plots in one figure.
There is a similar thread posing the same issue where the user is trying the scatter plot using the for loop but the too much computation power is consumed:
Also please refer to the stem3 functionality and to check if that can serve your purpose. Please refer to the below example:
figure
X = linspace(0,2*pi,50)';
Y = [cos(X), 0.5*sin(X)];
stem(X,Y)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/410485/image.png)
The current MATLAB version doesn't support matrix in the scatter signature but the future releases will see this update.
Thanks
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!