How to plot two trimesh plots together with different colour maps?
9 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am trying to use trimesh to plot two meshes onto one plot to compare the values, so I can visually see the areas\times where my numerical scheme might break etc. To do this I would find it very useful to change the colour of one of the plots.
Essentially I want to do the following:
T = delaunay(nodes(:,1),nodes(:,2));
nodes = [1:10', 1:10']
%Pressure and exct are column vectors
figure
trimesh(T,nodes(:,1),nodes(:,2), real(pressure))
hold on
colormap spring %Changing colour of second plot
trimesh(T,nodes(:,1),nodes(:,2), exct)
but annoyingly the above doesn't work. I can see that I can change the colour of the faces, but this isn't to helpful when I am trying to compare elements.
To help illustrate what I am after I have an example 1D plot and code:
figure
plot(nodes(:,1),nodes(:,1).^3,'r')
hold on
plot(nodes(:,1),nodes(:,1).^3+5, 'b')
which produces the following.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/333225/image.jpeg)
Any help would be great!
0 件のコメント
回答 (1 件)
Gouri Chennuru
2020 年 7 月 20 日
Hi Kieran,
Colormap sets the colormap for the current figure to one of the predefined colormaps. If you set the colormap for the figure, then axes and charts in the figure use the same colormap.
A colormap is matrix of values between 0 and 1 that define the colors for graphics objects such as surface, image, and patch objects. Each row in the matrix defines one color using an RGB triplet. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0, 1]. A value of 0 indicates no color and a value of 1 indicates full intensity.
As a possible workaround you can try
colormap([1 0 0;0 1 0]); % red and green color
Instead of colormap spring.
If colormap spring is used, colormap got overwritten in the target figure.so, the output isn’t reflecting as expected.
you can also check what is the existing color map by executing the command
cmap = colormap
Hope this Helps !
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!