mckinsey / qbstyles Goto Github PK
View Code? Open in Web Editor NEWQuantumBlack Matplotlib styles
License: Other
QuantumBlack Matplotlib styles
License: Other
Consider the following minimal working example which demonstrates unexpected behaviour when using qbstyles.mpl_style
with plt.savefig()
:
import matplotlib.pyplot as plt
from qbstyles import mpl_style
mpl_style(dark=True)
a = [1,2,3,4,5]
plt.plot(a)
plt.savefig('filename.png')
The output image is missing most elements and does not have the qbstyle applied:
Problem:
Proposed solution:
Background material:
Same image with qbstyles activated and deactivated: x-axis
and y-axis
are not indexed properly in the first image
# LINE PLOT
def line_plot(ax):
rng = np.random.RandomState(4)
x = np.linspace(0, 10, 500)
y = np.cumsum(rng.randn(500, 4), 0)
ax.set_title('Line Graph')
ax.set_xlabel('— Time')
ax.set_ylabel('— Random values')
ax.legend(['Bitcoin', 'Ethereum', 'Dollar', 'Oil'])
ax.set_xlim([0, 10])
ax.set_ylim([-20, 60])
ax.plot(x, y)
fig, ax = plt.subplots(figsize=(16, 9))
line_plot(ax)
If I install matplotlib through anaconda, my project gives a type error for argument 2 in pyplot line 671. After uninstalling the conda version and reinstalling the pip version the themes work as expected.
I am using the Spyder IDE. The same error occurs when run from the anaconda console.
A new style registration mechanism was introduced in matplotlib 3.7 that simplifies distributing styles a lot:
Third-party packages can now distribute style files that are globally available as follows. Assume that a package is importable as
import mypackage
, with amypackage/__init__.py
module. Then amypackage/presentation.mplstyle
style sheet can be used asplt.style.use("mypackage.presentation")
.
See https://matplotlib.org/stable/users/prev_whats_new/whats_new_3.7.0.html#style-files-can-be-imported-from-third-party-packages, matplotlib/matplotlib#4781, matplotlib/matplotlib#24257
Tangentially related: #12
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.