How can I change the color gradient when using interpolated shading in MATLAB 7.0.4 (R14SP2)?
4 次查看(过去 30 天)
显示 更早的评论
The following code creates a sphere and colors it using interpolated shading:
sphere(30)
axis equal
shading interp
I want to change the rate of shading within the sphere. For example,to make most of the sphere grey while coloring the rest of the sphere using interpolated shading.
采纳的回答
MathWorks Support Team
2009-6-27
The ability to change the interpolation method for the shading rate or color gradient is not available in MATLAB 7.0.4.
To work around this issue, manually adjust the extent to which a figure is shaded with a certain color by changing the colormap of the figure. For example, the following code will first color a sphere using the default colormap. It will then modify the figures's colormap to achieve a different color gradient.
sphere(30)
axis equal
colormap bone
a=colormap;
a(1:30,1:3)=.5;
colormap(a)
This displays a sphere with most of the sphere shaded from grey to white instead of from black to white. By appropriately changing the values of the colormap matrix (each element takes values between 0 and 1), it is possible to implement a desired shading scheme. You can also influence color gradients by specifying lighting characteristics, such as light position and the ratio of ambient and diffuse components.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!