Can I use different colormap settings on same 3D plot axes?
Afficher commentaires plus anciens
I have a 3D plot with a DEM (digital elevation model) plot that I plot using mesh() and render with the help of light()
On top of that I have various graphical elements (bullseye, text, borders) added using plot3().
Additionally I have a series of dots added using scatter3().
Is there a way to have a different colormap for the mesh() and the scatter3() plots ?

current view using the 'cool' colormap that applies to the whole figure (both the tracks in purple and the map in turquoise).
General overview of the code for the above plot:
opengl software % Hardware OpenGL rendering is unreliable for exporting images
figure('Renderer','opengl',...
'DefaultTextFontName', 'Miryad Pro', ...
'DefaultTextFontSize', 10,...
'DefaultTextHorizontalAlignment', 'right')
hold on
% >> load Xd, Yd, XYZ here <<
mesh(Xd, Yd, XYZ);
light
colormap('cool');
% >> load lines to x,y,z here <<
plot3(x,y,z,'-k')
% >> load scatter dots to x,y,z here <<
scatter3(x,y,vertiExag.*alt(filter).*0.3048,markSize,color(filter),'Marker','.')
% additional plot settings
axis equal
extra = 40e3; % some extra space around the bullseye
axis([xc-i-extra xc+i+extra yc-i-extra yc+i+extra])
set(gcf, 'Color', 'white');
axis off
% Prepare 3D view
pos = [0, 0, 1920+2, floor((1080+2)/0.8)]; % This gives a 854 x 480 mp4/gif whith the selected cropping
set(gcf, 'Position', pos);
axis vis3d
view(-7,20) % Some fiddling required!
camzoom(1.4) % Same here!
set(gca, 'LooseInset', [0,0,0,0]);
What I tried is using linkaxes for 2D plots
ax1 = axes;
mesh(ax1, Xd, Yd, XYZ);
light
colormap(ax1, 'cool');
hold(ax1, 'on');
plot3(ax1,x,y,z,'-k');
% so far so good
ax2 = axes;
scatter3(ax2,x,y,vertiExag.*alt(filter).*0.3048,markSize,color(filter),'Marker','.');
colormap(ax2, 'parula');
linkaxes([ax1, ax2]); %Link them together --> throws warning:
% Warning: linkaxes requires 2-D axes as input. Use linkprop for generic property linking
% Plot only shows data of scatter3 in 'parula' colors. Relief data is not displayed
this does not work:

2nd attempt using linkprop from:
ax1 = axes;
mesh(ax1, Xd, Yd, XYZ);
light
colormap(ax1, 'cool');
hold(ax1, 'on');
plot3(ax1,x,y,z,'-k');
% so far so good
ax2 = axes;
scatter3(ax2,x,y,vertiExag.*alt(filter).*0.3048,markSize,color(filter),'Marker','.');
colormap(ax2, 'parula');
% alternative with linkprop for 3D plots
Link = linkprop([ax1, ax2],{'CameraUpVector', 'CameraPosition', 'CameraTarget', 'XLim', 'YLim', 'ZLim'});
setappdata(gcf, 'StoreTheLink', Link);
% plot remains empty

I also tried this:
but since I use different plot types (plot3, scatter3 etc.)
All contents of the input cell array must be of the same data type.
Error in plotRTL1090_dem (line 167)
aH = cell2mat(ancestor(v,'axes'));
Could it be, that it is not possible at all?
Réponse acceptée
Plus de réponses (1)
Simon Burkhardt
le 10 Nov 2020
0 votes
Catégories
En savoir plus sur Polygons dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

