Patch - controlling transition of transparency - how to?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I made a plot where the patch background goes from a specific color to full transparency (not white color).
Question is: I would like to change the transparency limits and don't know how. You can see that for some peaks the blue color goes from deep blue to full transparency. Some of them don't, and I don't like that. I want every peak to have a transition from full blue to full transparency. Or better - precisely control it from-to. How to do it please?
I'm stuck on the FaceVertexAlphaData property and have no idea exactly what to put in it and how.
Working code snippet for all blue peaks:
% fit(:,1) is for X data, fit(:,i) is for Y data; data are in a columns
for i = 2:9
patch(fit(:,1),fit(:,i),'b','edgecolor','none','FaceAlpha','interp','FaceVertexAlphaData',fit(:,i)); % background
plot(fit(:,1),fit(:,i),'Color','b'); % edges
end
0 Commenti
Risposta accettata
Voss
il 8 Mar 2023
To have all patches span the full transparency range, use normalized values, where each column of fit is normalized separately.
% some matrix, I call it fitt (fit is a built-in function)
x = (71:169).';
fitt = [x 100*exp(-(x-110).^2/10) 50*exp(-(x-135).^2/30) 20*exp(-(x-95).^2/60)];
% normalize each column of fitt by dividing by its maximum
fitt_norm = fitt./max(fitt,[],1);
figure
hold on
% fitt(:,1) is for X data, fitt(:,i) is for Y data; data are in a columns
for i = 2:size(fitt,2)
patch(fitt(:,1),fitt(:,i),'b', ...
'edgecolor','none', ...
'FaceAlpha','interp', ...
'FaceVertexAlphaData',fitt_norm(:,i)); % background
plot(fitt(:,1),fitt(:,i),'Color','b'); % edges
end
5 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!