Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the label Fonts as "Time New Roman" by drawparallels in python

I have draw a map with latitudes labelled but I want to set the fonts as "Times New Roman". How to make it possible?

m.drawparallels(parallels,labels=[1,0,0,0],fontsize=12)

like image 462
Wang Tao Avatar asked Nov 22 '16 05:11

Wang Tao


People also ask

How do I increase the font size of a label in Python?

Tkinter Label Widgets are used to create labels in a window. We can style the widgets using the tkinter. ttk package. In order to resize the font-size, font-family and font-style of Label widgets, we can use the inbuilt property of font('font-family font style', font-size).

How do you change the font of a title in Python?

In Matplotlib, to set the title of a plot you have to use the title() method and pass the fontsize argument to change its font size. The above-used parameters are described as below: label: specifies the title. fontsize: set the font size of your choice.

How do you change font in python plot?

Create a figure and a set of subplots. Plot x data points using plot() method. To change the font size of the scale in matplotlib, we can use labelsize in the ticks_params()method. To display the figure, use show() method.


1 Answers

You need to set font family using pyplot of matplotlib.

import matplotlib.pyplot as plt
csfont = {'fontname':'Times New Roman'}
// write your code related to basemap here
plt.title('title',**csfont)
plt.show()

You can also use the following to change font globally.

import matplotlib.pyplot as plt
plt.rcParams["font.family"] = "Times New Roman"
like image 175
Wasi Ahmad Avatar answered Nov 14 '22 08:11

Wasi Ahmad