Overlaying gradient patches in single plot.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have created two gradient patches: the colormap for one goes from red to white (i.e., [1,0,0] --> [1, 1, 1]) over the range [1000,1600] along the x-axis of a subplot, while the other colormap goes from white to blue (i.e., [1, 1, 1] --> [0, 0, 1]/) over the range [1400, 2000] along the x-axis of a second subplot. xlim for both suplots is [1000, 2000], and I use a for loop with 256 iterations to create the colormaps. Is there any way to superimpose the two patches in one x-y plot (adjusting transparency so that both gradients are visible where the colored portions of the two patches overlap (i.e., x = 1400 --> 1600)? Thanks in advance.
3 Kommentare
Akzeptierte Antwort
darova
am 5 Jun. 2021
Bearbeitet: darova
am 5 Jun. 2021
See this
% x_lo = [1000 ; 1000; 1600; 1600]; % x-limits for RED gradient
% x_hi = [1400 ; 1400; 2000; 2000]; % x-limits for BLUE gradient
% y = [0; 500; 500; 0]; % y-limits for BOTH gradients
num_steps = 10;
x = [linspace(1000,1400,num_steps) linspace(1600,2000,num_steps)]; % x coord
X = [x;x]; % the same top and bottom
Y = [0*x;0*x+500]; % Y coord
c = linspace(0,1,num_steps); % color interpolatioon
red = interp1([0 1],[1 0 0;1 1 1],c); % create red chanel
blu = interp1([0 1],[1 1 1;0 0 1],c); % create blue chanel
C = reshape([red;blu],1,[],3); % 3D matrix of colors
C = [C;C]; % the same top and bottom
surf(X,Y,X*0,C)
view(0,90)
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Orange finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!