Comments (4)
Good question by the way; I'll include it in the planned FAQ section in the README (see #5). I'll close this issue in favor of the existing one. Feel free to comment further though.
from aquarel.
There currently is no automatic way to convert an existing stylesheet to aquarel
JSON, but two alternatives:
- drop the existing stylesheet into
set_overrides
; however, this will not convert to "proper" JSON, but just save the key-values of the stylesheet in the theme file - the manual way; i.e. have a look at the
aquarel.Theme
source code here: https://github.com/lgienapp/aquarel/blob/main/aquarel/theme.py#L98 – you can "reconstruct" which aquarel JSON keys correspond to which matplotlib rcparam keys and go from there to construct a new theme
Given the mapping is more or less reversible this could be automated, but it wouldnt be high on my priority list right now. But if you have time to figure it out, feel free to open a pull request.
from aquarel.
aquarel
is a wrapper around the stylesheets, so everything you can do with stylesheets can be achieved with aquarel
. However there are some notable shortcomings of stylesheets that aquarel
adresses:
- On-the-fly templating – the stylesheets are applied once and are then used for every plot in the current plotting context (py-file, notebook, ipython session, ...).
aquarel
takes a different approach here and aims to provide per-plot styling with optional temporary changes. The styleaquarel
applies lasts throughout the context manager (with aquarel.Theme:
), and switches back to whatever is the global default style outside of it. This allows you to do plot-level temporary changes. You have one plot in your notebook that needs no minor ticks? justwith theme.set_ticks():
for this plot only. - Simplified templating: matplotlib stylesheets have a lot of redundant keys for most applications. For example, you rarely want to have different colors for both axes; while possible with a stylefile, its cumbersome to change all the different keys to achieve a uniform look.
aquarel
simplifies this with e.x. a singleset_color(ticks="#eee")
call, which changes all related and relevant keys for ticks. Note that this simplifies the API, but does not restrict capabilities: theset_overrides
method accepts every possible stylefile key if you want to access low-level styling. - Transforms: some style elements, like trimmed axes, are not achievable with stylesheets alone (see README for more informations).
aquarel
defines a few of these transforms (and hopefully many more in the future), and makes them persistable and shareable through aquarel themes. Instead of having to apply a seaborn despine after every plot, you can have a global style that specifies a trim, and have consistent styling throughout with minimal code repitition.
from aquarel.
Thank you for these details, it is really clear, I like the fact it is a wrapper and not a drop-in replacement or alternative. I like the JSON format better also. Would you have an example of code to convert a stylesheet to the JSON format and conversely?
from aquarel.
Related Issues (20)
- Default themes do not specify line color
- scientific and boxy themes need minimum axes padding
- Add legend styling options
- KeyError: 'xtick.labelcolor' HOT 1
- Grid alpha value throws type error
- Pandas plots do not have a modified style applied
- Add unit tests
- set_tick_labels location parameter produces a value error HOT 2
- Add pytest CI
- Can not display in jupyter lab HOT 1
- Add transform for label rotation
- Add `from_context` class method to theme
- Conda package
- Add sphinx documentation
- Add FAQ to README
- Make filename split in list_themes more pythonic
- Include previews of different kinds of plots
- Trim transform should take axes argument
- Boxplot handles do not conform to selected theme colors
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aquarel.