Home > other >  Set the font size of the ticks of plot which is inside a plot
Set the font size of the ticks of plot which is inside a plot

Time:02-05

I am using the following code borrowed from here, to generate a zoomed-in plot inside a plot :

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()

To adjust the font size of the ticks of the zoomed-in plot, I tried the following:

sub_axes.xticks(fontsize=12) 

There is an error which says " 'Axes' object has no attribute 'xticks' ".

How to set the font size of the ticks of the zoomed-in plot?

CodePudding user response:

Try using plt.xticks(fontsize=12)

  •  Tags:  
  • Related