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

5 views (last 30 days)
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

Answers (1)

Pranav Verma
Pranav Verma on 11 Nov 2020
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:
X = linspace(0,2*pi,50)';
Y = [cos(X), 0.5*sin(X)];
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.

Community Treasure Hunt

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

Start Hunting!

Translated by