Overlaying gradient patches in single plot.
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
darova
2021 年 6 月 5 日
編集済み: darova
2021 年 6 月 5 日
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)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Orange についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!