fast plotting of matrix of unconnected data points (no lines) with reduced opacity

6 ビュー (過去 30 日間)
James Heald
James Heald 2020 年 7 月 31 日
回答済み: Pranav Verma 2020 年 11 月 11 日
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

回答 (1 件)

Pranav Verma
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)
You can set the opacity using gscatter. Please refer to the below discussion on the similar lines:
The current MATLAB version doesn't support matrix in the scatter signature but the future releases will see this update.
Thanks

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by