Two colormap in the same plot

42 views (last 30 days)
Cecilia Martinelli
Cecilia Martinelli on 11 May 2021
Answered: Pratyush Roy on 18 May 2021
Hello everyone,
I would like some help to plot two colormap in the same plot. I'm new to MatLab so I have still a lot to learn.
I have two dataset that I would like to plot with different colors. Here is my code, where I managed to plot them but just one has colors (trisurf). Now, I would like to plot in a different colormap (Parula) the dataset represented by the points in the figure (scatter), with a range between 0 and 100 cm.
% segment 12
subplot(2,2,1)
trisurf(tri_12,xf_12./1e3,yf_12./1e3,zf_12./1e3,ds_12,'EdgeColor','k','LineWidth',0.1)
hold on
scatter(coord(1:datind(1),1)./1e3,coord(1:datind(1),2)./1e3,20,d,'filled','MarkerEdgeColor','k') %
title(['Dip slip - segment 12',num2str(smth),',',num2str(SMOOTH(smth))])
view(az,el)
hcb=colorbar;
mycolormap=flipud(mymap);
colormap(mycolormap)
title(hcb,'m')
caxis([-10 10])
axis equal
xlabel('UTM easting (km)')
ylabel('UTM northing (km)')
zlabel('Depth (km)')
set(get(gca,'xlabel'),'rotation',35)
set(get(gca,'ylabel'),'rotation',-10)
Anyone can help me? I tried to adsjut my code following this answer but it didn't work, mainly because I think I didn't fully understand how to do.
Thanks

Answers (1)

Pratyush Roy
Pratyush Roy on 18 May 2021
Hi Cecilia,
The MathWorks Support Team has shared an answer with the community regarding how to use multiple colormaps in a single plot. The link to the answer is given here.
Hope this helps!

Community Treasure Hunt

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

Start Hunting!