Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

QuantumBlack Matplotlib styles

License

NotificationsYou must be signed in to change notification settings

mckinsey/qbstyles

Repository files navigation

LicensePython VersionPyPI versionCode Style: Black

QB Styles is a python package with a light and a darkmatplotlib style.

Dark styleLight style
Line plotDistribution plot

How do I install QB Styles?

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

pip install qbstyles

How do I use QB Styles?

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

fromqbstylesimportmpl_stylempl_style(dark=True)

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

fromqbstylesimportmpl_stylempl_style(dark=False)

How do I use QB Styles in Jupyter Notebooks?

⚠️ Please make sure you runfrom qbstyles import mpl_style andmpl_style() indifferent cells as shown below. Seethis issue for more details.

# first cellfromqbstylesimportmpl_style
# second cellmpl_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 inexample.ipynb, install the required packages usingpip install -r requirements_notebook.txt in a Python virtual environment of your choice.

importmatplotlib.pyplotaspltfromqbstylesimportmpl_styledefplot(dark):mpl_style(dark)fig,axes=plt.subplots(2,2,figsize=(15,10))# the following functions are defined in example.ipynbline_plot(axes[0,0])scatter_plot(axes[0,1])distribution_plot(axes[1,0])ax=plt.subplot(2,2,4,projection='polar')polar_plot(ax)plot(dark=True)

png

plot(dark=False)

png

How do I create my own styles?

Have a look at the filesqb-common.mplstyle,qb-dark.mplstyle andqb-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 theqbstyle as follows:

importmatplotlib.pyplotaspltfromqbstylesimportmpl_stylempl_style()plt.style.use('./your-style.mplstyle')

All ofmatplotlibrc's options can be foundhere.

What licence do you use?

QB Styles is licensed under theApache 2.0 License.


[8]ページ先頭

©2009-2025 Movatter.jp