Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XTickLabel font size change indepent of Y-axis?

2,328 views
Skip to first unread message

Matthias

unread,
May 28, 2010, 11:21:30 AM5/28/10
to
Is it true that x-axis tick label font size cannot be controlled independently of y-axis tick label font size in Matlab?

I have tried solutions to related posts, but these don't appear to work in my case:

-----
ah = gca;
set(ah,'YTick',1:60);

hold on
for ii = 1:length(data(1,:))
try
plot(spikes(2:end,ii)/1000,(ii*ones(1,length(spikes(2:end,ii)))),'r.','MarkerSize', 4)
ylabel('\bfElectrode channel','FontSize',10)
title('\bfCH72, spikes across all channels', 'FontSize', 12)
catch exception
end
end

xlim([-10 260])
ch = measort(1:60,'lin');

set(ah,'YTickLabel',num2str(ch'), 'FontSize',4)
-------

The last code changes BOTH x and y axis label font size, even though only YTickLabel was specified. But I don't want my x-axis ticklabel fonts to be 4.

If this is indeed asking too much, can I at least hide the unreadable x-axis tick labels?

Walter Roberson

unread,
May 28, 2010, 11:39:33 AM5/28/10
to
Matthias wrote:

> set(ah,'YTickLabel',num2str(ch'), 'FontSize',4)

> The last code changes BOTH x and y axis label font size, even though
> only YTickLabel was specified.

Matlab is constructed so that the order of named parameters in set()
only matters for the Unit and Position properties; if it had a distinct
X Tick font size and Y Tick font size, it would use different names for
them, such as 'XFontSize' and 'YFontSize'. If you look at the axes_props
documentation you will see there is only one FontSize for the axes. And
as you have indirectly discovered, there is no Interpreter property for
tick labels.

> If this is indeed asking too much, can I at least hide the
> unreadable x-axis tick labels?

You can use patch() or rectangle() to put a box of the background color
over the labels. You may need to specify a z coordinate greater than 0
for the box. When you go to text() the new labels into place, be sure to
use a z coordinate greater than your box to be sure the new labels will
be in front of the box (well, this is actually only a consideration if
you are using the OpenGL renderer.)

Matthias

unread,
May 31, 2010, 3:00:21 AM5/31/10
to
Walter Roberson <robe...@hushmail.com> wrote in message <VsRLn.22580$Gx2....@newsfe20.iad>...


Thanks for your reply.
A colleague showed me an even easier way to hide the x-axis tick labels:
set(ah,'XTickLabel',[])

Pekka Kumpulainen

unread,
Jun 1, 2010, 1:39:06 PM6/1/10
to
"Matthias " <matthew...@bcf.uni-freiburg.de> wrote in message <htvmq5$d7s$1...@fred.mathworks.com>...

There are several functions in the File Exchange that will replace the TickLabels with normal text objects providing full control. Well, all the properties of text objects anyway..
hth

Emil

unread,
Aug 14, 2010, 9:19:04 AM8/14/10
to
Try this, if you're still looking for a solution:

figure; axes;
xlabel('not to change')
ylabel('\bfElectrode channel')
h = findobj('string','\bfElectrode channel');
set(h,'FontSize',18)

Emil

unread,
Aug 14, 2010, 9:20:05 AM8/14/10
to
0 new messages