Two colormap in the same plot

조회 수: 54 (최근 30일)
Cecilia Martinelli
Cecilia Martinelli 2021년 5월 11일
답변: Pratyush Roy 2021년 5월 18일
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

답변 (1개)

Pratyush Roy
Pratyush Roy 2021년 5월 18일
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!

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by