How can I change the font size of tick labels on the axes of a graph?

306 visualizaciones (últimos 30 días)
I have tried all of the suggestions in fx, Help and answers to other people's questions, but I cannot make any of them work in Matlab 2020a.

Respuestas (2)

Cris LaPierre
Cris LaPierre el 29 de Mayo de 2020
Editada: Cris LaPierre el 29 de Mayo de 2020
It's in the documentation under axes properties:
plot(1:5)
ax=gca;
ax.FontSize = 20
You can also change a single axis by specifying that axis:
ax.XAxis.FontSize = 20
  5 comentarios
Cris LaPierre
Cris LaPierre el 2 de Jun. de 2020
You likely replied to an email notification from MATLAB Central. Replies are not actually directed to anyone.
I've poked around in your code. I didn't attempt to explore every plot, but if I were you, I would probably set the properties this way.
title(strcat('Basilar Membrane Velocity Transfer Function, Excitation @',Stringt,sprintf('\n Frequency = %0.0f Hz,',f(fn)),Comp))
ylabel(strcat('Basilar Membrane velocity amplitude (dB)',Stringy))
xlabel('Distance from Stapes (mm)')%lgd.Title.String = 'Frequency (kHz)';
ax=gca;
ax.XAxis.FontSize = 12;
ax.YAxis.FontSize = 12;
ax.XLabel.FontSize = 24;
ax.YLabel.FontSize = 14;
ax.Title.FontSize = 18;
Was there a particular plot that was not working?
Giuseppe Degan Di Dieco
Giuseppe Degan Di Dieco el 27 de Abr. de 2021
Dear Cris,
your solution worked for me too.
Thanks for your brilliant help.
Best!

Iniciar sesión para comentar.


David Slater
David Slater el 3 de Jun. de 2020
Cris,
Thanks for your response. Your suggested way of specifying font sizes is much more rational than mine, and so I have tried it both for one plot in my full script and for the simplified script below. Running the script after executing a clear command results in your graph with 20pt tick labels, followed by my graph still with 12pt tick labels and no title or axis titles. Any thoughts?
figure(1)
plot(1:5 )
ax=gca ;
ax.FontSize = 20
f=logspace(log10(20),log10(20000),100);
HL0=linspace(0,50);
figure(6)
title('Measured and Predicted Hearing Loss (Reduction in BM Velocity) with no Bubble')
ylabel('Post Implant Hearing Loss (dB)')
xlabel('Frequency (Hz)')
ax=gca;
ax.XAxis.FontSize = 20;
ax.YAxis.FontSize = 20;
ax.XLabel.FontSize = 20;
ax.YLabel.FontSize = 20;
ax.Title.FontSize = 36;
semilogx(f,20*log10(HL0),'LineWidth', 3,'color','r')
grid on
There are two graphs that particularly need a larger font for the tick labels: figures 6 and 7 in my full script. I have deleted the many sections that create the other graphs, and I have attached the result. (To reduce the run time, I have also reduced the number of iterations necessary in the sections that do the calculations; this makes the graphs a bit more notchy, but it makes no difference to font sizes.)
David.
  5 comentarios
David Slater
David Slater el 10 de Jun. de 2020
Cris,
I haven't heard from you in a while; do I need to open a new question, or do you still have this in hand?
David.
David Slater
David Slater el 1 de Jul. de 2020
Cris,
Because I have heard nothing further from you or anyone at Mathsoft in weeks, I had to try to find the problem myself by trial and error. Mathsoft and/or its customers may be interested in what I have found. The problem appears to be with the "load" function. If I load the workspace with a .mat file, this prevents the script from changing the font sizes. If I delete the "load" command from the script, then the code that you suggested and the code that I was using previously both work. I can manage without using the "load" function, but doing so is inconvenient, and it will become more so as my project develops. Am I doing something wrong, or is this a bug?
Please respond to this, even if only to ask me to open a new question.
David.

Iniciar sesión para comentar.

Categorías

Más información sobre Install Products en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by