Ask Your Question
1

Change font size for all texts in a graph

asked 2016-10-20 22:02:31 +0100

Massimo2013 gravatar image

Is it possible to set the font size for all labels in a plot? I have been able to set the font family changing the internal parameters of matplotlib

from matplotlib import rc
rc('text',usetex=True)
rc('font',**{'family':'serif','serif':['Times']})

I'd like to change the size as well, so that all labels created with 'text' are the same size (note that I want to use TeX in labels)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2016-10-22 11:07:16 +0100

ndomes gravatar image

A quite simple way without touching matplotlib configuration:

kwds = {'color':'red','fontsize':16,'fontweight':'bold','rotation':30}
G = Graphics()
G += text('TEST',(2,1),**kwds)
G += text('TEST',(-2,1),**kwds)
G.show()
edit flag offensive delete link more

Comments

you need the two astherics? I mean, writing just kwds will not work too?

Masacroso gravatar imageMasacroso ( 2016-10-23 12:48:19 +0100 )edit
0

answered 2016-10-21 23:06:00 +0100

Have you tried adding 'size' : number to your font dictionary?

http://matplotlib.org/api/matplotlib_...

edit flag offensive delete link more

Comments

Adding 'size' : number seems to have no effect.

ndomes gravatar imagendomes ( 2016-10-22 00:17:09 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-10-20 22:02:31 +0100

Seen: 1,338 times

Last updated: Oct 22 '16