Plotting lines with patch and transparency
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dear community,
I am trying to use the patch function in order to draw lines with a level of transparency (alpha), but it does not seem to work (apparently patch is faster than plot when we have too many lines)
I have followed the guidelines from a Youtube video, by changing the last row value into NaN:
cycle.P_CY01(end,:).Variables=NaN(1,2003); % 7200 x 2003 matrix
Whenever my alpha variable is below 1, the lines will not be plotted:
alpha=zeros(1,2001)+.9;
alpha(:,idx)=1; % idx is the indexes of the lines I want to be above the others
The color is defined as follows:
color=ones(7200,2001);
color(:,1)=0;
color(:,idx)=2;
I am using the patch function the following way to plot:
patch(CKAISYS, cycle.P_CY01(:,3:end).Variables,... % CKAISYS is 7200x2001, with last row being NaN
color,'EdgeColor','flat','EdgeAlpha','flat',...
'FaceVertexAlphaData',alpha',"HandleVisibility","off");
colormap([black; grey; orange]) % where black, grey, and orange are predefined RGB triplets
Only the lines with alpha=1 will be plotted, the ones with 0.9 value will not be plotted. I want the lines with alpha=1 to be above the ones being at 0.9.
Isn't there a simpler way to do it? If I could directly assign RGB+alpha triplet (so nx4 matrix), instead of relying on colormap, that would be great.
Optional:
- I am looking for a way to add the proper legend entry for each of these colors
- I would like to have the first column with thicker linewidth (2 instead of 1)
I have looked up this website but it didn't help me too much: Patch Properties (MATLAB Functions) (northwestern.edu)
Thank you
1 comentario
dpb
el 30 de En. de 2023
I think if you want anybody here to try to diagnose/debug this you'll need to attach a standalone demo code snippet that illustrates the issue you're having. We can't run your code and it's too much to expect somebody to try to make up something from scratch that would match what you're after.
Respuestas (1)
Sarvesh Kale
el 14 de Mzo. de 2023
Hi Benjamin Pehlivanlar,
You might find the following matlab answer useful
0 comentarios
Ver también
Categorías
Más información sobre Graphics Performance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!