How can I add a space below the title?
78 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I have the next code.
figure(1), clf;
% Plotting T C
subplot(3,1,1)
pcolor(gridx/1000,gridy/1000,tk1-273);
shading interp;
axis tight;
colormap(jet);
title(['T (^oC),' ' Time = ',num2str(timesum*1e-6/(365.25*24*3600)), ' (Myr)'])
colorbar;
axis ij image;
I am getting the image, but I have a problem. The title is overlapping the figure, so I want to add some space between the title and the figure but I do not know how to do that.
Thank you very much.
0 commentaires
Réponses (2)
Askic V
le 15 Nov 2022
If you need to add space below your title, you can add newline, something like this:
title(['T (^oC),' ' Time = ',num2str(timesum*1e-6/(365.25*24*3600)), ' (Myr)', newline])
newline is more convenient to use comparing with sprintf('\n') for example .
2 commentaires
Askic V
le 15 Nov 2022
In order to change the position of the title, you can use the Position property of the title .
Please have a look at this thread:
https://www.mathworks.com/matlabcentral/answers/408173-title-position-below-the-x-axis.
Image Analyst
le 15 Nov 2022
I actually find sprintf() much easier to read than having a bunch of extra apostrophes, commas, and function calls to num2str():
caption = sprintf('T (^oC), Time = %f (Myr)\n', timesum*1e-6/(365.25*24*3600))
t = title(caption);
You can add addition \n if you want to add additional space that is a whole line space. Use the Position property of the title handle:
caption = sprintf('T (^oC), Time = %f (Myr)\n', timesum*1e-6/(365.25*24*3600))
titleHandle = title(caption)
% Place title at the left side of the plot by using the Position property:
ax = gca; % ax.Position is [xLeft, yTop, width, height] of the axes.
titleHandle.Position = [ax.Position(1), titleHandle.Position(2:end)];
0 commentaires
Voir également
Catégories
En savoir plus sur Title dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!