How can I add a space below the title?
79 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Askic V
am 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 Kommentare
Askic V
am 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
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Title finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!