Ask Your Question
1

Change font size for all texts in a graph

asked 2016-10-20 15:02:31 -0500

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 04:07:16 -0500

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 05:48:19 -0500 )edit
0

answered 2016-10-21 16:06:00 -0500

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-21 17:17:09 -0500 )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 15:02:31 -0500

Seen: 113 times

Last updated: Oct 22 '16