Clear Filters
Clear Filters

plot two figures with same colorscale

5 views (last 30 days)
Herlan
Herlan on 12 Nov 2014
Answered: Luuk van Oosten on 17 Nov 2014
Hi all,
I want to plot x,y,z data with z as time series data in several figures. I want to plot using plot3. However, I found difficulties to plot that figures in same color scale. I have make a script like this :
clear;
x=xlsread('Merapideformation.xlsx', 'A:A');
y=xlsread('Merapideformation.xlsx', 'B:B');
z1=xlsread('Merapideformation.xlsx', 'D:D');
z2 = xlsread('Merapideformation.xlsx', 'E:E');
clear Merapideformation
bottom = min(min(min(z1)), min(min(z2)));
top = max(max(max(z1)), max(max(z2)));
subplot(1,2,1)
plot3(x,y,z1,'.');
view (5,90)
caxis manual
caxis ([bottom top]);
subplot(1,2,2)
plot3(x,y,z2,'.')
view (5,90)
caxis manual
caxis ([bottom top]);
colorbar;
However, when I run the script, the plot was just in blue color. It makes me difficult to analyze in time series. Does anybody can help me? thank you in advance.

Answers (2)

Hugo
Hugo on 12 Nov 2014
If I understood correctly, you want the colour to vary according to the value of "z". But the problem is that plot3 takes only one colour for the whole line. Furthermore, the colour is not affected by caxis.
The solution may be to use scatter3 instead. It seems that you are just plotting points, so it should be fine. Hope this helps.
  2 Comments
Herlan
Herlan on 12 Nov 2014
Yes, I want to compare z value in the same region but in different time. I already tried to use scatter3 but the color scale was different. So, it made me difficult to analyze the spatial changing in different time.
Do you have an idea to make two or more figures with same colorscale in matlab? using plot3 or scatter3? thanks
Hugo
Hugo on 17 Nov 2014
Sorry for the delay.
The colour scale in scatter3 can be modified with caxis and thus can be made the same. The colours of each point in scatter3 can be specified as one of the inputs of scatter3. That is, if you write scatter3(x,y,z,10,z), it would plot points of size 10 and each point will have a colour proportional to the value of z in that point. Then the colormap can be changed using the command "colormap" followed by some predefined value or by a colormap of your own
Hope this helps.

Sign in to comment.


Luuk van Oosten
Luuk van Oosten on 17 Nov 2014
I tried something similar with scatter3. A slight modification of this answer will solve your problem.

Community Treasure Hunt

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

Start Hunting!