设置绘图内绘图刻度的字体大小

Set the font size of the ticks of plot which is inside a plot

我正在使用从 here 借来的以下代码在绘图中生成放大图 :

import numpy as np
from matplotlib import pyplot as plt

# Generate the main data
X = np.linspace(-6, 6, 1024)
Y = np.sinc(X)

# Generate data for the zoomed portion
X_detail = np.linspace(-3, 3, 1024)
Y_detail = np.sinc(X_detail)

# plot the main figure
plt.plot(X, Y, c = 'k')  

 # location for the zoomed portion 
sub_axes = plt.axes([.6, .6, .25, .25]) 

# plot the zoomed portion
sub_axes.plot(X_detail, Y_detail, c = 'k') 

plt.show()

为了调整放大图刻度的字体大小,我尝试了以下方法:

sub_axes.xticks(fontsize=12) 

出现错误“'Axes' 对象没有属性 'xticks'”。

如何设置放大图刻度的字体大小?

尝试使用 plt.xticks(fontsize=12)