我正在尝试对图进行缩放,但是我不知道如何在图的“缩放部分”中放置线性比例。我只想编写缩放的x和y范围。 有人知道该怎么办吗? 下面是图片的链接
from mpl_toolkits.axes_grid.inset_locator import inset_axes
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.axes_grid1.inset_locator import mark_inset
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
from scipy.interpolate import interp1d
t1 = np.loadtxt("d=12_ye=0.1txt", usecols = [1])
T1=10**t1
ynu1 = np.loadtxt("d=12_ye=0.1txt", usecols = [3])
ynub1 = np.loadtxt("d=12_ye=0.1txt", usecols = [4])
fig = plt.figure(figsize=(9, 4),facecolor='white')
ax = fig.add_subplot(111)
plt.plot(T1, ynu1)
plt.plot(T1, ynub1)
plt.axis([0, 100, -20,100])
plt.xlabel('T[Mev]')
plt.ylabel('Fractions')
plt.legend(['ynu','ynub'], loc='lower left')
plt.plot(T1,T1-T1,color='black',linestyle='dashed')
# this is an inset axes over the main axes
inset_axes = inset_axes(ax,
width="50%", # width = 30% of parent_bbox
height=1.5, # height : 1 inch, loc=2)
plt.plot(T1, ynu1)
plt.plot(T1, ynub1)
plt.plot(T1,T1-T1,color='black',linestyle='dashed')
plt.axis([0, 9, -0.03, 0.03])
plt.yticks(visible = False)
plt.xticks(visible = False)
mark_inset(ax, inset_axes, loc1=2, loc2=4, fc='none', ec='0.5')
plt.tight_layout()
plt.show()