Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
killiansheriff committed Mar 6, 2024
1 parent 9710538 commit ae3f400
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lovelyplots/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# From https://github.com/garrettj403/SciencePlots/blob/master/scienceplots/__init__.py
from os import listdir
from os.path import isdir, join

import matplotlib.pyplot as plt

import lovelyplots

# register the included stylesheet in the matplotlib style library
lovelyplots_path = lovelyplots.__path__[0]
styles_path = join(lovelyplots_path, 'styles')

# Reads styles in /styles
stylesheets = plt.style.core.read_style_directory(styles_path)
# Reads styles in /styles subfolders
for inode in listdir(styles_path):
new_data_path = join(styles_path, inode)
if isdir(new_data_path):
new_stylesheets = plt.style.core.read_style_directory(new_data_path)
stylesheets.update(new_stylesheets)

# Update dictionary of styles
plt.style.core.update_nested_dict(plt.style.library, stylesheets)
# Update `plt.style.available`, copy-paste from:
# https://github.com/matplotlib/matplotlib/blob/a170539a421623bb2967a45a24bb7926e2feb542/lib/matplotlib/style/core.py#L266
plt.style.core.available[:] = sorted(plt.style.library.keys())

0 comments on commit ae3f400

Please sign in to comment.