Changing font size using xlabel

[EDIT: Mon Jun 6 16:32:41 UTC 2011 - Reformat - MKF]
Hello, I am putting a label on a graph using xlabel, and I want to increase the size of the font (to about 30) and possibly bold it (although, this is less important and I have not yet tried this).
I have tired using:
xlabel(text, 'FontSize', 30)
but this produces no notable change in the font size. Thank you in advance for your help!
Edit:
Using:
h = xlabel(printnombrejpg,'FontSize',60);
get(h)
Returns:
Annotation = [ (1 by 1) hg.Annotation array]
BackgroundColor = none
Color = [0 0 0]
DisplayName =
EdgeColor = none
Editing = off
Extent = [-435.849 -11.5896 837.736 8.69217]
FontAngle = normal
FontName = Helvetica
FontSize = [60]
FontUnits = points
FontWeight = normal
HorizontalAlignment = center
LineStyle = -
LineWidth = [0.5]
Margin = [2]
Position = [-5.76923 -4.46355 1.00011]
Rotation = [0]
String = cr45f__ch_24
Units = data
Interpreter = tex
VerticalAlignment = cap
BeingDeleted = off
ButtonDownFcn =
Children = []
Clipping = off
CreateFcn =
DeleteFcn =
BusyAction = queue
HandleVisibility = off
HitTest = on
Interruptible = on
Parent = [222.028]
Selected = off
SelectionHighlight = on
Tag =
Type = text
UIContextMenu = []
UserData = []
Visible = on

4 Comments

Mmm, pretty weird. Do you have the code?
try changing the color just to make sure you are interacting with the correct handle
This is the code that I am using:
f=gcf;
printnombrejpg=strcat(cellname, '_ch_ ', num2str(neuronchan(cell)));
xlabel(printnombrejpg, 'FontSize', 100)
However, the font size does not change. Nor does it change with the methods suggested below... very weird! Thank you, everyone, for your answers!
do you know how to do this in the GUI?

Sign in to comment.

 Accepted Answer

I suggest you edit your original post (read: don't make a new answer) to include the output from this:
xl = xlabel(printnombrejpg, 'FontSize', 100);
get(xl) % Show what this returns...

6 Comments

Thank you for posting _some_ of the output from the GET function. You did miss some of the properties... in particular I wanted to see the 'visible' property.
Now, just to make sure you are looking at the correct string, does this do anything:
set(h,'color',[1 .4 .4])
And which OS are you using?
Hi Matt, the rest of the output is now in the original post, sorry about that. I am using Linux. The font changed to red with the set function.
Aha, that is what I was wondering. I found a similar complaint on the net, here:
http://www.linuxquestions.org/questions/linux-software-2/matlab-fontsize-problem-in-fedora-12-a-804635/
Perhaps the discussion over there will help! Come back and let us know if the fix found there helps your issue...
I think all that they did was install some new fonts to the system. Perhaps it would work for you if you just try to switch the 'fontname' property of the xlabel to a font you have. Do you have courier?
Thank you for finding this! (Sorry for the late reply).
I'm not sure if I have a courier, is there a way that I can find out? Hopefully this will fix the problem.
do you know how to do this in the GUI?

Sign in to comment.

More Answers (2)

h=xlabel('mylabel') %or h=get(gca,'xlabel')
set(h, 'FontSize', 30)
set(h,'FontWeight','bold') %bold font
Well it works for me!
I would suggest you try:
h = xlabel(text,'FontSize',30);
get(h)
and examine the properties. Specifically FontUnits

3 Comments

It tells me that the font size is 60 (I set it to 60 this time), but the font still appears to be the same size as before..
FontUnits says "points"
do you know how to do this in the GUI?

Sign in to comment.

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Asked:

A
A
on 6 Jun 2011

Commented:

on 30 Mar 2017

Community Treasure Hunt

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

Start Hunting!