TL;DR: I cannot remove or adjust xticks from inset_axis.
I was trying to prepare a zoom-in plot, where a box will display a zoomed version of the plot. However, the x-ticks of the zoomed in plot were too entangled and I decided to manually assign them.
This is a snip from the original plot.
So I tried the following lines:
inset_axe.set_xticks([])
inset_axe.set_yticks([])
It indeed removed the yticks, but xticks are not affected.
Here is a minimum working example. The issue persists in the MWE as well.
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import numpy as np
import matplotlib.pyplot as plt
#####Just creating random N,Q function
a=0.1
Q=np.linspace(-5,4,1000)
M=a*np.ones(2000)
P=1.4**4*np.ones(2000)+a
N=[1.4**(x)+a for x in Q]
N=np.asarray(list(M)+N+list(P))
Q=np.logspace(-9,6,5000)
####################################
g, axes = plt.subplots(1)
inset_axe = inset_axes(axes,width="60%", height="25%", loc='lower left',
bbox_to_anchor=(0.6,0.15,0.7,.7), bbox_transform=axes.transAxes)
inset_axe.semilogx(Q[2200:2400],N[2200:2400])
inset_axe.set_yticks([])
inset_axe.set_xticks([])
axes.semilogx(Q,N)
plt.show()
Is this a bug or do I have a small mistake that I cannot see? Is there a way around this?
If it helps, I use Microsoft VS and matplotlib version is 3.3.3.
question from:
https://stackoverflow.com/questions/65893413/removing-or-adjusting-ticks-for-inset-axis 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…