mwaskom / seaborn

Statistical data visualization in Python
https://seaborn.pydata.org
BSD 3-Clause "New" or "Revised" License
12.55k stars 1.92k forks source link

related projects #22

Closed arsenovic closed 10 years ago

arsenovic commented 10 years ago

this project is great, and the aesthetics are thoughtfully designed. i love it. it would be nice for these style-improvements to be incorporated into mpl.

also, if you aren't already aware, tony yu is working on a similar project https://github.com/tonysyu/mpltools

he recently implemented the styles feature into mpl https://github.com/matplotlib/matplotlib/pull/2236

arsenovic commented 10 years ago

possibly a lot of your rcmod.py could be implemented as style sheets.

https://github.com/matplotlib/matplotlib/tree/master/lib/matplotlib/style/stylelib

mwaskom commented 10 years ago

Yeah, I was thinking about that recently. The one thing is that I'm not sure how stylesheets would handle the context-dependent aspects of the seaborn styles? I actually think the implementation of this in seaborn.rcmod is extremely janky, but I haven't thought of a better way. Maybe I could write some stylesheet templates and then plug in values based on the context and send those to the mpl style system?

arsenovic commented 10 years ago

i assume you are referring to the palette_context function? i actually didnt notice this feature until you mentioned it. it seems like the mpl styles could be swapped out in an identical way as seaborn color palettes . i think that its a great idea, and i would use it. perhaps @tonysyu could provide some advice on this?

mwaskom commented 10 years ago

Ah, no, but reasonable confusion. The "context" parameter in seaborn.set() doesn't mean context in the sense of a context manager (like palette_context), but in terms of setting the aesthetics to have the same general look but with features tweaked for figures intended to end up in an interactive notebook vs. slides for a talk, an academic paper, etc: http://stanford.edu/~mwaskom/software/seaborn/aesthetics.html#changing-style-contexts

arsenovic commented 10 years ago

ok, i see. so.... my understanding is that your contexts are exactly what tony calls styles.? maybe ill pull the current maplotlib and try to add a *.mplstyle similar to seaborn. in either case, i think using python's context manager (like you did with palette_context) would allow this to be tweaked from kwargs on-the-fly .

arsenovic commented 10 years ago

ok, i started making a style file, and see why it may be tricky; the effects of changing the style and context, are not totally independent, (but mostly are)

if they were totally independent, the different styles and contexts could be done with several .mplstyles that are loaded in series. however given the slight inter-mixing, you would have to have separate .mplstyles for each combination of context and style to retain current functionality.

inserting the .mplstyle functionality in between the steps of creating and applying these mpl rc-settings can be done, basically creating a seaborn_mplstyle_generator() function. but i dont see huge benefit, except that they could be saved to disk, and you could re-use the mpl context manager function.

mwaskom commented 10 years ago

Yep, that's where the problems are.

I expect the style implementation to change (and hopefully stabilize) a bit over the next release or two. It might be better to revisit this then.