Multiple trisurf plots with different colours

7 views (last 30 days)
Good day,
I have made two plots using Matlab's trisurf command:
trisurf(tri1,X1,Y1,Z1);
hold on
trisurf(tri2,X2,Y2,Z2);
hold off
The second plot is located much lower on the grid compared to the first plot.
When I only plot the X1,Y1,Z1 data, the graph looks fine. However, when the second plot is added, the colours of the first plot change. Now I like to add the second plot (X2,Y2,Z2) without influencing the colours of the first plot (X1,Y1,Z1).
So summarised, I want to use the trisurf plot twice on the same screen but I do not want one plot to influence the other (that is the colours).
Thank you in advance!

Answers (1)

Thomas
Thomas on 17 Apr 2013
You can set your color range to manual to prevent auto-scaling:
caxis manual
after the first before the second surf. However if Z2 is completely out of range of Z1 colors may not fit.
  2 Comments
Pieter
Pieter on 17 Apr 2013
Thank you for your reply.
Unfortunately this does not work. The Z2 values are about 10 times as small as the Z1 values.
Thomas
Thomas on 17 Apr 2013
I am unsure what you want to achieve. Normally, there is one color scale that maps a range of values to colors. The 4th parameter in trisurf, C, tells matlab how to find the colors for your surface(points). In your case C is Z1 for the first and Z2 for the second surface plot. So, the smaller a value in Z1 (or Z2) is, the more bluish it gets and the larger it is the more reddish(for the default jet colormap).
You have complete freedom in passing other values as C to adjust your colors. For example, if the values in Z1 range from 0 to 100 and the ones in Z2 range from 0 to 10 you could do a
trisurf(tri1,X1,Y1,Z1);
hold on
trisurf(tri2,X2,Y2,*10*Z2*);
hold off
to put the color values for the second plot in the same range as the first ones (0...100).

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!