lgienapp / aquarel Goto Github PK
View Code? Open in Web Editor NEWStyling matplotlib made easy
License: MIT License
Styling matplotlib made easy
License: MIT License
The PyPi version of the README cannot render the images due to relative paths. Fix: make image urls absolute.
theme = load_theme("arctic_dark").set_tick_labels(location="top")
theme.apply()
produces
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In [2], line 2
1 theme = load_theme("arctic_dark").set_tick_labels(location="top")
----> 2 theme.apply()
File ~/Documents/aquarel/aquarel/theme.py:325, in Theme.apply(self)
323 if mapped_key == "axes.prop_cycle":
324 value = cycler("color", value)
--> 325 mpl.rcParams.update({sub_key: value})
326 else:
327 # Special treatment for color palette, as this is otherwise not JSON serializable
328 if mapped_key == "axes.prop_cycle":
File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/_collections_abc.py:940, in MutableMapping.update(self, other, **kwds)
938 if isinstance(other, Mapping):
939 for key in other:
--> 940 self[key] = other[key]
941 elif hasattr(other, "keys"):
942 for key in other.keys():
File ~/Documents/aquarel/venv/lib/python3.9/site-packages/matplotlib/__init__.py:648, in RcParams.__setitem__(self, key, val)
646 cval = self.validate[key](val)
647 except ValueError as ve:
--> 648 raise ValueError(f"Key {key}: {ve}") from None
649 dict.__setitem__(self, key, cval)
650 except KeyError as err:
ValueError: Key xaxis.labellocation: 'top' is not a valid value for xaxis.labellocation; supported values are ['left', 'center', 'right']
If location is left
ValueError: Key yaxis.labellocation: 'left' is not a valid value for yaxis.labellocation; supported values are ['bottom', 'center', 'top']
In the docs, valid options are given as this:
location (Optional[str]) – location of the tick labels, can be {“left”, “right”, “bottom”, “top”, “center”}, default: center
I just did a pip install.
from aquarel import list_themes
list_themes()
returns
[]
and load_theme("arctic_light")
raises
ValueError: No theme named 'arctic_light' found.
Windows 11, Anaconda Python 3.9 installation.
I stepped into the code, it is globbing 'C:\anaconda3\lib\site-packages\aquarel\themes\*.json', but there is no
themes subdirectory in 'C:\anaconda3\lib\site-packages\aquarel, and a search of my drive confirms that arctic_light.json is not anywhere on my drive.
As an aside, I recommend using os.path.join to create the filepath, you have hardcoded in unix style with f"{loc}/themes/*.json"
os.path.join(loc, 'themes', '*.json')
matplotlib==3.3.4. Require a minimum version of matplotlib module.
Compile docstrings into a sphinx documentation and publish it
with load_theme("arctic_light").set_grid(axis="x"):
pd.Series(sizes).sort_values().plot.bar()
produces
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/tmp/ipykernel_16842/1244744067.py in <module>
----> 1 with load_theme("arctic_light").set_grid(axis="x"):
2 pd.Series(sizes).sort_values().plot.bar()
/media/ssd/BIGSCIENCE/env/lib/python3.7/site-packages/aquarel/theme.py in set_grid(self, draw, axis, ticks, alpha, style, width)
432 "axis": axis if axis in self._axis_options else None,
433 "ticks": ticks if ticks in self._tick_options else None,
--> 434 "alpha": alpha if 0 <= alpha <= 1 else None,
435 "style": style if style in self._line_style_options else None,
436 "width": width,
TypeError: '<=' not supported between instances of 'int' and 'NoneType'
I'm trying aquarel in jupyter lab, but it's doesn't work sometimes (can't display in jupyter lab page).
You may try this code:
import numpy as np
import matplotlib.pyplot as plt
from aquarel import load_theme
x = np.linspace(0, 10, 1000)
sinx = np.sin(x)
cosx = np.cos(x)
with load_theme('boxy_light'):
plt.subplot(2, 1, 1)
plt.plot(x, sinx)
plt.plot(x, cosx)
plt.subplot(2, 1, 2)
plt.plot(x, cosx)
plt.show()
My environment:
python: 3.10.8
aquarel: 0.0.5
matplotlib: 3.5.2
Each set_
method should have an associated unit test that checks if the underlying matplotlib.rcparams
are updated successfully and correctly.
Use os.basename instead of split-syntax
Possible Questions:
set
call directly?Add the option for a theme to be created from the current matplotlib plotting contexts' rcparams
.
The trim function should take an optional axes argument, can be "x", "y", or "both".
Having zero padding leads to problems with e.x. barplots, as the lowermost and uppermost flier are drawn on top of the axis and are thus invisible.
This article shows how to use it https://www.datafantic.com/the-magic-of-matplotlib-stylesheets/.
Despite the format which is different it looks like it is another way to do do a declarative templating
When using
with load_theme("umbra_light"):
pd.Series({"ROOTS":1.6, "OPT":1.02, "GPT3":1.63, "The Pile":0.89}).sort_values().plot.bar()
the style is applied as expected. However, any set_
calls on the style are not. Instead using seaborn to plot instead of pandas fixes it. Why?
Add a transform to rotate axis labels
Introduce a set_legend
option to style the legend.
Maybe also legend-specific transforms, for example location?
Each theme should be previewed as regression, boxplot, and barplot.
Plot generation should be moved to seaborn example datasets to make it more interesting.
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.