项目作者: quantumblacklabs

项目描述 :
QuantumBlack Matplotlib styles
高级语言: Jupyter Notebook
项目地址: git://github.com/quantumblacklabs/qbstyles.git
创建时间: 2019-02-07T16:22:29Z
项目社区:https://github.com/quantumblacklabs/qbstyles

开源协议:Other

下载


QB Styles

License
Python Version
PyPI version
Code Style: Black

QB Styles is a python package with a light and a dark matplotlib style.

Dark style | Light style
|—————-|—————- |
| Line plot | Distribution plot |

How do I install QB Styles?

qbstyles is a Python package. To install it, simply run:

  1. pip install qbstyles

How do I use QB Styles?

You can use the dark Matplotlib style theme in the following way:

  1. from qbstyles import mpl_style
  2. mpl_style(dark=True)

And to use the light Matplotlib style theme, you can do the following:

  1. from qbstyles import mpl_style
  2. mpl_style(dark=False)

How do I use QB Styles in Jupyter Notebooks?

⚠️ Please make sure you run from qbstyles import mpl_style and mpl_style() in different cells as shown below. See this issue for more details.

  1. # first cell
  2. from qbstyles import mpl_style
  1. # second cell
  2. mpl_style()

What chart types can use QB Styles?

  • Line plots
  • Scatter plots
  • Bubble plots
  • Bar charts
  • Pie charts
  • Histograms and distribution plots
  • 3D surface plots
  • Stream plots
  • Polar plots

Can you show me a few examples?

To run the examples in example.ipynb, install the required packages using pip install -r requirements_notebook.txt in a Python virtual environment of your choice.

  1. import matplotlib.pyplot as plt
  2. from qbstyles import mpl_style
  3. def plot(dark):
  4. mpl_style(dark)
  5. fig, axes = plt.subplots(2, 2, figsize=(15, 10))
  6. # the following functions are defined in example.ipynb
  7. line_plot(axes[0, 0])
  8. scatter_plot(axes[0, 1])
  9. distribution_plot(axes[1, 0])
  10. ax = plt.subplot(2, 2, 4, projection='polar')
  11. polar_plot(ax)
  12. plot(dark=True)

png

  1. plot(dark=False)

png

How do I create my own styles?

Have a look at the files qb-common.mplstyle, qb-dark.mplstyle and qb-light.mplstyle. They contain many elements that you may want to customise.

To do so, create a file similar to the above files at the root of your project, and apply it after the qbstyle as follows:

  1. import matplotlib.pyplot as plt
  2. from qbstyles import mpl_style
  3. mpl_style()
  4. plt.style.use('./your-style.mplstyle')

All of matplotlibrc‘s options can be found here.

What licence do you use?

QB Styles is licensed under the Apache 2.0 License.