All Projects → erwanp → publib

erwanp / publib

Licence: MIT license
Produce publication-level quality images on top of Matplotlib

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to publib

dufte
📈 Minimalistic Matplotlib style
Stars: ✭ 196 (+476.47%)
Mutual labels:  matplotlib, matplotlib-style-sheets, matplotlib-styles
Scienceplots
Matplotlib styles for scientific plotting
Stars: ✭ 2,937 (+8538.24%)
Mutual labels:  matplotlib-style-sheets, scientific-papers, matplotlib-styles
heatmaps
Better heatmaps in Python
Stars: ✭ 117 (+244.12%)
Mutual labels:  plot, matplotlib
mltb
Machine Learning Tool Box
Stars: ✭ 25 (-26.47%)
Mutual labels:  plot, matplotlib
bitrate-plotter
Plots a graph showing the bitrate every second or the bitrate of every GOP, for a video or audio file.
Stars: ✭ 15 (-55.88%)
Mutual labels:  plot, matplotlib
matplotx
📊 More styles and useful extensions for Matplotlib
Stars: ✭ 507 (+1391.18%)
Mutual labels:  matplotlib, matplotlib-style-sheets
sarviewer
Generate graphs with gnuplot or matplotlib (Python) from sar data
Stars: ✭ 60 (+76.47%)
Mutual labels:  plot, matplotlib
matplotlib-haskell
Haskell bindings for Python's Matplotlib
Stars: ✭ 80 (+135.29%)
Mutual labels:  plot, matplotlib
Tensorflow Plot
📈 TensorFlow + Matplotlib as TF ops
Stars: ✭ 285 (+738.24%)
Mutual labels:  plot, matplotlib
Vapeplot
matplotlib extension for vaporwave aesthetics
Stars: ✭ 483 (+1320.59%)
Mutual labels:  plot, matplotlib
Adjusttext
A small library for automatically adjustment of text position in matplotlib plots to minimize overlaps.
Stars: ✭ 731 (+2050%)
Mutual labels:  plot, matplotlib
Itermplot
An awesome iTerm2 backend for Matplotlib, so you can plot directly in your terminal.
Stars: ✭ 1,267 (+3626.47%)
Mutual labels:  plot, matplotlib
reddit-hot-recorder
Records the activity (comments and karma) on the hot page of a Reddit sub and prepare an animated data visualisation.
Stars: ✭ 89 (+161.76%)
Mutual labels:  plot, matplotlib
nodeplotlib
NodeJS plotting library for JavaScript and TypeScript. On top of plotly.js. Inspired by matplotlib.
Stars: ✭ 115 (+238.24%)
Mutual labels:  plot, matplotlib
Rustplotlib
A Rust's binding of matplotlib
Stars: ✭ 31 (-8.82%)
Mutual labels:  plot, matplotlib
Matplotlib4j
Matplotlib for java: A simple graph plot library for java with powerful python matplotlib
Stars: ✭ 107 (+214.71%)
Mutual labels:  plot, matplotlib
Hep
hep is the mono repository holding all of go-hep.org/x/hep packages and tools
Stars: ✭ 146 (+329.41%)
Mutual labels:  plot
Lets Plot Kotlin
Kotlin API for Lets-Plot - an open-source plotting library for statistical data.
Stars: ✭ 181 (+432.35%)
Mutual labels:  plot
Aachartkit Swift
📈📊📱💻🖥️An elegant modern declarative data visualization chart framework for iOS, iPadOS and macOS. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types. 极其精美而又强大的跨平台数据可视化图表框架,支持柱状图、条形图、…
Stars: ✭ 1,962 (+5670.59%)
Mutual labels:  plot
G2plot
🍡 An interactive and responsive charting library
Stars: ✭ 2,072 (+5994.12%)
Mutual labels:  plot

PyPI version Tests Code coverage

Publib

Description

Produce publication-level quality images on top of Matplotlib, with a simple call to a couple functions at the start and end of your script.

Project GitHub page

For similar librairies, see the References section.

Install

pip install publib

Use

At the beginning of the script, call:

set_style()

After each new axe is plotted, call:

fix_style()

Note that importing publib will already load the basic style.

A few more styles ('poster', 'article', etc.) can be selected with the function set_style()

Because some matplotlib parameters cannot be changed before the lines are plotted, they are called through the function fix_style() which:

  • changes the minor ticks

  • remove the spines

  • turn the legend draggable by default

Examples

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

A default Matplotlib plot:

mpl.rcdefaults()

x = np.linspace(0,5,250)
y = np.cos(x)**2+np.random.normal(scale=0.5,size=len(x))
yav = np.cos(x)**2
plt.figure()
ax = plt.subplot()
ax.plot(x,y,'o',label='normal distribution')
ax.plot(x,yav,zorder=-1,label='average')
plt.xlabel(r'$x$')
plt.ylabel(r'$\cos^2 x$+noise')
plt.title('matplotlib')
plt.legend(loc='upper left')
plt.ylim((-1.5,3.5))
plt.show()
plt.savefig('mpl_default.png')

mpl_defaults.png

And now the same code with the two new lines calling the publib functions

from publib import set_style, fix_style
set_style('article')        # before the first plot

x = np.linspace(0,5,250)
y = np.cos(x)**2+np.random.normal(scale=0.5,size=len(x))
yav = np.cos(x)**2
plt.figure()
ax = plt.subplot()
ax.plot(x,y,'o',label='normal distribution')
ax.plot(x,yav,zorder=-1,label='average')
plt.xlabel(r'$x$')
plt.ylabel(r'$\cos^2 x$+noise')
plt.title('article')
plt.legend(loc='upper left')
plt.ylim((-1.5,3.5))

fix_style('article')  # after the axe has been created

plt.show()
plt.savefig('publib_article.png')

publib_article.png

The OriginPro style:

set_style('origin')

...

fix_style('origin')

publib_origin.png

A combination of styles:

set_style(['poster', 'origin'])

...

fix_style(['poster', 'origin'])

publib_poster_origin.png

Or, assuming you have the Latin Modern Math font installed:

set_style(['origin', 'latex'])

...

fix_style(['origin', 'latex'])

publib_origin_latex.png

Run the test() routines in publib.test for more examples.

Tools

The publib.tools module include independant functions to fix some common matplotlib bugs, or include extra features. They're usually glanced from somewhere on the web. Proper
referencing is made in the function docstrings.

See for instance:

  • publib.tools.reset_defaults: reset Matplotlib defaults

  • publib.tools.regenerate_fonts: rebuild Matplotlib font cache

  • publib.tools.fix_bold_TimesNewRoman: fix Times New Roman font appearing bold. See StackOverflow

  • publib.tools.keep_color: apply the same color for the next graph to plot

  • publib.tools.get_next_color: see which color will be applied next in the color cycle state

plt.plot(...)
keep_color()
plt.plot(...)
  • publib.tools.list_font_names: to list all fonts available in Python.

See tools.py for more details

Changes

  • 0.2.2: added tools

  • 0.1.9: added talk and OriginPro style

  • 0.1.7 : default fonts to Times in article

References

Some other interesting packages to make nice graphs in Matplotlib.

Add new features:

Style based:

Tips and demos of Matplotlib:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].