Giter VIP home page Giter VIP logo

Comments (4)

lgienapp avatar lgienapp commented on May 16, 2024 1

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.

lgienapp avatar lgienapp commented on May 16, 2024 1

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.

lgienapp avatar lgienapp commented on May 16, 2024

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:

  1. 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 style aquarel 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? just with theme.set_ticks(): for this plot only.
  2. 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 single set_color(ticks="#eee") call, which changes all related and relevant keys for ticks. Note that this simplifies the API, but does not restrict capabilities: the set_overrides method accepts every possible stylefile key if you want to access low-level styling.
  3. 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.

mazzma12 avatar mazzma12 commented on May 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.