I tried to create two polar scatter plots, one being a zoom-in of the other. I have no problem configuring the font properties of the angular axis, but my attempts to change the fonts of the radial axis have not been successful.
I have tried using the font_manager to define the font:
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.font_manager import FontProperties
#define font
baseFont = FontProperties(family='Helvetica',fname=[path to the .ttf file])
a = np.random.uniform(-np.pi/2,np.pi/2,100)
d = np.random.uniform(0,20,100)
c = np.random.uniform(0,1,100)
fig, sub = plt.subplots(1,2,subplot_kw={'polar':[True,True]})
#configure the ticks
aTicks = np.linspace(-np.pi/2,np.pi/2,7,endpoint=True)
aLabels = np.linspace(-90,90,7,endpoint=True)
dTicks1 = np.arange(0,20.1,5)
dTicks2 = np.arange(0,5.1,1)
#plot the first graph
sub[0].scatter(a,d,c=c,cmap='hsv')
sub[0].set_thetamin(-90)
sub[0].set_thetamax(90)
sub[0].set_ylim(0,20.1)
sub[0].set_xticks(aTicks,labels=aLabels,font=baseFont,fontsize=12)
sub[0].set_yticks(dTicks1,labels=dTicks1,font=baseFont,fontsize=12)
sub[1].scatter(a,d,c=c,cmap='hsv')
sub[1].set_thetamin(-90)
sub[1].set_thetamax(90)
sub[1].set_ylim(0,5.1)
sub[1].set_xticks(aTicks,labels=aLabels,font=baseFont,fontsize=12)
sub[1].set_yticks(dTicks2,labels=dTicks2,font=baseFont,fontsize=12)
plt.show()
The angular axis tick font is changed to Helvetica, while the radial axis tick font remains the default font.
I have also tried changing the tick densities and confirm that sub[0].set_yticks() can affect the radial axis tick marks, but the only thing that does not change is the tick label font. The resulting image is attached.
Plot result
Hosea Chan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.