Reputation: 3
I wanted to included a title into my 3D plot in Matlab, but the problem I'm facing right now is that if I rotate the plot, the title also moves. Does anyone know how to fix its location no matter how much you rotate your plot?
Thanks!
Upvotes: 0
Views: 808
Reputation: 13945
As a workaround you can add a textbox at the top and make it's background color the same as the figure (normally gray; [0.8 0.8 0.8]). Try out the following:
close all
clc
clear
[X,Y,Z] = peaks(25);
figure;
surf(X,Y,Z);
%// Use uicontrol to place a fixed text box.
uicontrol('Style','text','Position', [200 400 200 20],'String','Super fixed title!','FontSize',16,'HorizontalAlignment','Center','BackgroundColor',[.8 .8 .8])
rotate3d on
It looks like this and it does not move!
Note that if you resize the figure it will move around. To fix this you need to use normalized units in the definition of the figure:
figure('Units','normalized');
Hope that helps!
Upvotes: 1