GithubHelp home page GithubHelp logo

kristjaneerik / brokenaxes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bendichter/brokenaxes

0.0 2.0 0.0 97 KB

Create matplotlib plots with broken axes

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

brokenaxes's Introduction

brokenaxes

brokenaxes logo. Reference: http://www.brianhensley.net/2012/02/python-controlling-spi-bus-on.html

brokenaxes makes matplotlib plots with breaks in the axes for showing data across a discontinuous range.

PyPI

Installation

I recommend the Anaconda python distribution

pip install brokenaxes

Usage

import matplotlib.pyplot as plt
from brokenaxes import brokenaxes
import numpy as np

fig = plt.figure(figsize=(5,2))
bax = brokenaxes(xlims=((0, .1), (.4, .7)), ylims=((-1, .7), (.79, 1)), hspace=.05)
x = np.linspace(0, 1, 100)
bax.plot(x, np.sin(10 * x), label='sin')
bax.plot(x, np.cos(10 * x), label='cos')
bax.legend(loc=3)
bax.set_xlabel('time')
bax.set_ylabel('value')

example1

Create subplots:

from brokenaxes import brokenaxes
from matplotlib.gridspec import GridSpec
import numpy as np

sps1, sps2 = GridSpec(2,1)

bax = brokenaxes(xlims=((.1, .3),(.7, .8)), subplot_spec=sps1)
x = np.linspace(0, 1, 100)
bax.plot(x, np.sin(x*30), ls=':', color='m')

x = np.random.poisson(3, 1000)
bax = brokenaxes(xlims=((0, 2.5), (3, 6)), subplot_spec=sps2)
bax.hist(x, histtype='bar')

example2

Features:

  • Break x and y axes.
  • Supports multiple breaks on a single axis.
  • Automatically scales axes according to relative ranges.
  • Plot multiple lines.
  • Legend with positioning relative to entire broken axes object
  • x and y label centered to entire plot
  • Make brokenaxes object a subplot itself with matplotlib.GridSpec.subplot_spec.
  • xlims and ylims may be datetime.datetime objects

Gallery:

If you make a plot that you are proud of with this tool, send me a png and code and I'll add it to the gallery!

Life advice

Please use this tool wisely. Any data visualization techique can be used to elucidate trends in the data, and can be used to manipulate and mislead. The latter is particularly true for broken axes plots, so please try to use them responsibly. Other than that, this software is free to use for any purpose.

brokenaxes's People

Contributors

bendichter avatar parkus avatar pharshalp avatar

Watchers

James Cloos avatar (Kristjan) Eerik Kaseniit avatar

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.