1

First of all, my question has partially answered in theses posts (How to zoom a part of plot by Matplolib, Matplotlib/Pandas: Zoom Part of a Plot with Time Series), but I can't comment over there because I'm newbie on the community and don't have permission to do that.

So, said this, my code is producing this graph: enter image description here

Is exactly what I wanted, but the zoom is to small, and when I change the zoom, the aspect ratio of the box change proportionally. For 8x zoom:

enter image description here

I've tried to change aspect ratio of the axins, but just don't work, and the zoom that I want is very large, to capture the fluctuations of the lines near to zero:

enter image description here

Beside this, the code is plotting the zoom with different color from the original lines. Of course I can note that this is because I'm making the plot twice times, one for ax and other for axins. How can I fix this?

from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes 
from mpl_toolkits.axes_grid1.inset_locator import mark_inset

fig=plt.figure()
sns.set_style('whitegrid', {'legend.frameon':True})
sns.set_palette("deep")

fig= plt.subplots(figsize=(10,5))
ax=plt.axes()
ax.plot(me_re5200['y^+'],me_re5200['U'],markevery=0.2,marker='o',label='$\\overline{u}$ em Re = 5200')
ax.plot(me_re2000['y^+'],me_re2000['U'],markevery=0.3,marker='o',label='$\\overline{u}$ em Re = 2000')
ax.plot(me_re5200['y^+'],me_re5200[' W'],markevery=0.2,marker='o',label='$\\overline{w}$ em Re = 5200')
ax.plot(me_re2000['y^+'],me_re2000['W'],markevery=0.3,marker='o',label='$\\overline{w}$ em Re = 2000')

plt.xscale('symlog')
plt.grid(True)
plt.ylabel("$U^+$")
plt.xlabel('$y^{+}$')
plt.xlim(1,None)
plt.legend(frameon=True,edgecolor='grey',loc=6)

x1,x2=30,80
y1,y2=-1,1

axins=zoomed_inset_axes(ax, 2,loc='center right') # 2 = zoom
axins.plot(me_re5200['y^+'],me_re5200[' W'],markevery=0.2,marker='o')
axins.plot(me_re2000['y^+'],me_re2000['W'],markevery=0.3,marker='o')
plt.xscale('symlog')

axins.axis([x1, x2, y1, y2])
plt.xticks(visible=False)
plt.yticks(visible=True)
mark_inset(ax, axins, loc1=2, loc2=4, fc="none", ec="0.5")
plt.draw()
plt.show()
Alessandro Melo
  • 150
  • 1
  • 9

0 Answers0