Skip to content

A dataroots inspired style for Matplotlib. Works with any visualization tools that builds upon Matplotlib (seaborn, pandas).

License

Notifications You must be signed in to change notification settings

datarootsio/rootsstyle

Repository files navigation

dataroots PyPI version Python Versions codecov semantic-release: angular

A matplotlib styling package for clean, minimal dataroots themed plots. Works with any visualization tools that builds upon Matplotlib (seaborn, pandas).

Installation

using pip

pip install rootsstyle

using poetry

poetry add rootsstyle

Usage

Examples

import rootsstyle
import matplotlib.pyplot as plt

plt.style.use(rootsstyle.style)
y, y2 = [3, 8, 1, 10], [8, 3, 10, 2]
plt.plot(y, label='y')
plt.plot(y2, label='y2', linestyle = 'dotted')
rootsstyle.ylabel('yvalues')
plt.xlabel('x-label')
rootsstyle.legend()
plt.title('Example plot')
plt.show()
import rootsstyle
import matplotlib.pyplot as plt

plt.style.use(rootsstyle.style)
languages = ['C', 'C++', 'Java', 'Python', 'PHP']
students = [23,17,35,29,12]
plt.bar(languages, students)
plt.xlabel('Language')
rootsstyle.show_bar_values()
plt.title('Example barplot')
plt.show()

STYLING

import rootsstyle
import matplotlib.pyplot as plt

# globally
plt.style.use(rootsstyle.style)

# within context manager
with plt.style.context(rootsstyle.style):
    # ...

FUNCTIONS

  • Place the legend to the right of the plot.
    For lineplots, place the legend entries right of the corresponding line.

    rootsstyle.legend(handles=None, labels=None, title=None)
  • Place the y-label above the y-axis and rotate it, so that it is horizontal.

    rootsstyle.ylabel(ylabel: str)
  • Show barvalues at each bar.
    Removes the y-axis (optional).
    Bar values can be shown just 'below' the top of each bar, or just 'above' each bar.

    rootsstyle.show_bar_values(remove_y_axis=True, fontsize=12, position="below", fmt="{:.0f}")

COLOR PALETTE

The color palettes are added to the global matplotlib color registry. You can thus easily use a palette by simply providing the name in the correct location.

VERSIONING

A semantic versioning scheme is used to update the version on the commit messages. This happens automatically on any push to the main branch. Only patches, minor and major changes will generate a tag, release and publishing of the package. We stick to the default Angular Commit Message Conventions. To use this system, commit messages should adhere to a couple of rules:

  1. Commits must follow the following syntax

    <type>(<scope>): <subject>
    <BLANK LINE>
    <body>
    <BLANK LINE>
    <footer>
    
  2. Type should be one of the following:

    • feat: A new feature
    • fix: A bug fix
    • docs: Documentation only changes
    • style: Changes that do not affect the meaning of the code (formatting, missing semi-colons, etc)
    • refactor: A code change that neither fixes a bug nor adds a feature
    • perf: A code change that improves performance
    • test: Adding missing or correcting existing tests
    • chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
  3. Body (optional) is used to motivate the change

  4. Footer (optional) is used to link to any issues that the commit closes and for breaking changes, in which case the line should start with BREAKING CHANGE:.

CHANGELOG

The CHANGELOG.md file is automatically updated upon any new releases.

License

This project is licensed under the terms of the MIT license.

About

A dataroots inspired style for Matplotlib. Works with any visualization tools that builds upon Matplotlib (seaborn, pandas).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages