change Axis ticklabel font size

295 visualizaciones (últimos 30 días)
MINA
MINA el 7 de Mzo. de 2016
Comentada: BK Shouharda el 28 de Jun. de 2021
I am trying to change the font size of Xticklabel by this code
a = get(gca,'XTickLabel');
set(gca,'XTickLabel',a,'fontsize',12,'FontWeight','bold')
in a figure where I have 6 subplots and I do this for each subplot separately. However when I get my figure the order of the numbers on the axis are wrong, for example on X axis it shows: [0 500 1000 0 500 1000]. I realized that sometimes if I only set one axis (either X or Y) it would automatically apply on both axis and I don't get this error. But I tried that on each subplot and still doesn't work.
Could you please help me what I can do to solve this issue?

Respuestas (2)

Alexander Cranney
Alexander Cranney el 3 de Oct. de 2018
Editada: Alexander Cranney el 3 de Oct. de 2018
I was having this same issue. It's easier in 2015B, but some users of my plotting GUI were using 2015A, so I had to figure out how to make it work in 2015A. Try the below code:
a = get(gca,'XTickLabel');
set(gca,'XTickLabel',a,'fontsize',12,'FontWeight','bold')
set(gca,'XTickLabelMode','auto')

Walter Roberson
Walter Roberson el 7 de Mzo. de 2016
Every subplot is an axes by itself. Axes do not "contain" subplots: each subplot is a full independent axes that happens to be positioned nicely relative to other axes.
Up to R2014a, the axes fontname property affects the x, y, and z axes at the same time and they cannot be varied independently. The situation for R2014b is a bit confused. As of R2015a, there is are XAxis, YAxis, and YAxis components of axes that can have their FontName properties set independently.
Is it possible that you are using plotyy() or plotxx() ? Those create additional axes that are "below" what is obvious. If you were to set the properties of one of the two plotyy or plotxx axes without setting the other appropriately, you could end up with multiple labels showing up. If you are using plotyy only one of the two x axes should have its XTick set or else you will get duplicate ticks. If you are using plotxx only one of the two y axes should have its YTick set or else you will get duplicate ticks.

Community Treasure Hunt

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

Start Hunting!

Translated by