Giter VIP home page Giter VIP logo

zoomedinsetaxis's Introduction

ZoomedInsetAxis

Example image

This is a function that can be used with matplotlib for Python 3+ to create an inset axis that is a zoomed-in version of the parent axis, inspired by the ax.inset_axis. Make sure ZoomedInsetAxis.py is in your current working directory or Python PATH directory. Then, import it as,

from ZoomedInsetAxis import zoomed_inset_axis

Then, call it using,

zoomed_inset_axis(ax,((x0,y0),(x1,y1)))

where ax is the axis you want to zoom in on and x0, y0, x1, and y1 are the data coordiantes.

This function currently only supports zooming in on axes which contain Line2D and PathCollection objects, which are created by plt.plot and plt.scatter, respectively. It is not guaranteed that the zoomed-in axis will be an exact copy of the parent axis, but it is pretty darn close. After the axis is created, you can work on it as with any regular matplotlib Axes object.

By default, the zoomed-in axis has no tick labels and its tick marks correspond to that of the parent axis.

You can specify the zoom level using the keyword zoom (default is 2), which takes either a 2-tuple, float, or integer. If a 2-tuple is specified, the inset axis will be zoomed in by a factor of zoom[0] on the x-axis and zoom[1] on the y-axis. Otherwise, both axes will be zoomed by a factor of zoom.

You can specify where you want the inset axis placed with the loc keyword, which accepts values, 'upper left','upper right','lower left','lower right', or 0,1,2,3 correspondingly.

You can change the padding the inset axis has with the parent axis with the borderaxespad keyword, which accepts a 2-tuple, float, or integer measured as fraction of the parent axis. The default value is (matplotlib.rcParams['axes.xmargin'],matplotlib.rcParams['axes.ymargin']).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.