Skip to content

Instantly share code, notes, and snippets.

@sadimanna
Last active August 2, 2020 03:10
Show Gist options
  • Select an option

  • Save sadimanna/b676f13f96e221b9d956dda2ef617ceb to your computer and use it in GitHub Desktop.

Select an option

Save sadimanna/b676f13f96e221b9d956dda2ef617ceb to your computer and use it in GitHub Desktop.
# loc values
# 2---8---1
# | | |
# 6---10--5/7
# | | |
# 3---9---4
axins1 = zoomed_inset_axes(ax, zoom = 5, loc=2)
axins1.plot(y,datapts.T)
axins1.plot(y,datapts.T,'mo')
# SPECIFY THE LIMITS
x1, x2, y1, y2 = 24,26,54.5,56
axins1.set_xlim(x1, x2)
axins1.set_ylim(y1, y2)
# FOR ANNOTATING THE 3 POINTS WE ARE ZOOMING ON
for dpt,ypt in zip(datapts.T[3],[25]*4):
if dpt > y1 and dpt < y2:
axins1.annotate("%.2f"%(dpt),xy=(ypt,dpt),textcoords='data')
# IF SET TO TRUE, TICKS ALONG
# THE TWO AXIS WILL BE VISIBLE
plt.xticks(visible=False)
plt.yticks(visible=False)
mark_inset(ax, axins1, loc1=1, loc2=4, fc="none", ec="0.5")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment