https://github.com/phyks/replot
An attempt at an easier API to plot graphs using Matplotlib.
https://github.com/phyks/replot
Last synced: 6 months ago
JSON representation
An attempt at an easier API to plot graphs using Matplotlib.
- Host: GitHub
- URL: https://github.com/phyks/replot
- Owner: Phyks
- License: mit
- Created: 2016-03-01T13:51:51.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-19T15:17:22.000Z (over 9 years ago)
- Last Synced: 2025-01-22T12:23:01.886Z (11 months ago)
- Language: Jupyter Notebook
- Homepage:
- Size: 12.3 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Replot
======
This repo is an attempt for a better API to plot graphs with
[Matplotlib](http://matplotlib.org/) in Python.
`Matplotlib` is a wonderful Python modules to plot data series, functions and
so on. However, I think the API is quite verbose. This is an attempt at
providing a better frontend API on top of `matplotlib` for easy and fast
plotting, especially at prototyping time.
## Features
These are the current features. I will extend the module whenever I feel the
need to introduce new functions and methods. Please let me know about any bad
design in the API, or required feature!
- Saner default plots
- Matplotlib plots are quite ugly by default, colors are not really
suited for optimal black and white print, or ease reading for colorblind
people. This module defines a clean default colorscheme to solve it (based
on Colorbrewer Q10 palette). It also provides direct access to the
Tableau10 and Colorbrewer Q9 palettes. - Support
withstatement - Ever got tired of having to start any figure with a call to
matplotlib.pyplot.subplots()? This module abstracts it using
withstatement. New figures are defined by a
withstatement, and areshown automatically (or
saved) upon leaving thewithcontext. - Plot functions
- Ever got annoyed by the fact that
matplotlibcan only
plot point series and not evaluate a function à la Mathematica?
This module let you do things likeplot(sin, (-10, 10))to
plot a sine function between -10 and 10, using adaptive sampling. - Order of call of methods is no longer important
- When calling a method from
matplotlib, it is directly
applied to the figure, and not deferred to the final render call. Then, if
callingmatplotlib.pyplot.legend()before
having actuallyplotted anything, it will fail. This is not
the case with this module, as it abstracts on top of
matplotliband do the actual render only when the figure is
to beshown. Even after having called theshow
method, you can still change everything in your figure! - Does not interfere with
matplotlib - You can still use the default
matplotlibif you want, as
matplotlibstate and parameters are not directly affected by
this module, contrary to whatseaborndo when you import it
for instance. - Useful aliases
- You think
loc="top left"is easier to remember than
loc="upper left"in amatplotlib.pyplot.legend()
call? No worry, this module aliases it for you! (same for "bottom" with
respect to "lower"). Similarly, you can usexrangeor
xlimarguments to specify axes ranges (respectively
yrange/ylim). - Automatic legend
- If any of your plots contains a
labelkeyword, a legend
will be added automatically on your graph (you can still explicitly tell
it not to add a legend by setting thelegendattribute to
False). - Use
LaTeXrendering inmatplotlib, if
available. - If
replotfindsLaTeXinstalled on your
machine, it will overloadmatplotlibsettings to use
LaTeXrendering. - Handle subplots more easily
- Have you ever struggled with
matplotlibto define a subplot
grid and arrange your plot?replotlets you describe your
grid visually using ascii art! - "Gridify"
- You have some plots that you would like to arrange into a grid, to
compare them easily, but you do not want to waste time setting up a grid
and placing your plots at the correct place?replothandles
it for you out of the box! - Easy plotting in log scale, orthonormal axis etc
-
replotdefineslogplotand
loglogplotshortcuts functions to plot in log scale
or loglog scale. Useorthonormal=Trueon a
plotcommand to plot using orthonormal axes.
## Examples
A more up to date doc is still to be written, but you can have a look at the
`Examples.ipynb`
[Jupyter](https://github.com/jupyter/notebook/) notebook for
examples, which should cover most of the use cases.
## License
This Python module is released under MIT license. Feel free to contribute and
reuse. For more details, see `LICENSE.txt` file.
## Thanks
* [Matplotlib](http://matplotlib.org/) for their really good backend.
* [Seaborn](https://github.com/mwaskom/seaborn) and
[prettyplotlib](http://blog.olgabotvinnik.com/prettyplotlib/) which gave me
the original idea.
* [This code](http://central.scipy.org/item/53/1/adaptive-sampling-of-1d-functions)
from scipy central for a base code for adaptive sampling.
* [Palettable](https://jiffyclub.github.io/palettable/) for palettes.
* [Cubehelix](http://www.ifweassume.com/2013/05/cubehelix-or-how-i-learned-to-love.html)
colorscheme for nice black and white printing and desaturation compatibility.