Info
此问题已关闭。 请重新打开它进行编辑或回答。
Hi, I have shaped an area between two graphs with one color, but I want that the shade area changes the color with rising yaxis.
1 次查看(过去 30 天)
显示 更早的评论
My yaxis is temperature from 0 to 40, so in the beginning it should be blue or green and by reaching 40 it should be dark red and color changes by temperature should be very smooth. I could figure colorbar out, but could not use it really. Any help is highly appreciated.
0 个评论
回答(1 个)
Star Strider
2016-6-1
Try this:
x = linspace(0, 30);
t1 = 20 + 0.5*x;
t2 = 10 + 0.3*x;
c = [t1 flip(t2)];
figure(1)
patch([x flip(x)], [t1 flip(t2)], c, 'FaceColor','interp')
grid
xlabel('Distance (km)')
ylabel('Temperature (°C)')
colormap(jet(100))
<<www-mathworks-com-matlabcentral-answers-uploaded_files-53446-Hi--20I-20have-20shaped-20an-20area-20between-20two-20graphs-20with-20one-20color--20but-20I-20want-20that-20the-20shade-20area-20changes-20the-20color-20with-20rising-20yaxis-20--202016-2006-2001.png>>
2 个评论
Star Strider
2016-6-2
My pleasure.
That it ‘did not work’ does not give me any useful information.
It should not make a difference if they are linear or non-linear. I would have to have your data and your code to determine what the problem is.
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!