thebeat
thebeat copied to clipboard
Don't force a style onto users of plotting functions
The current default style for all plots is some old, deprecated version of seaborn's style, through matplotlib.
This does not seem correct or extandable. If I apply my own style before plotting, I don't want it to be overwritten by seaborn!
For example, the following code does not use seaborn's modern "white" style:
import seaborn as sns
with sns.axes_style("white"):
seq.plot_sequence()
As far as I can tell, there's also no way to force this (modern, non-v0_8
version of) seaborn style, as seaborn or other libraries do not extend the plt.style.available
list.
At a minimum, this should work, by taking None
as default parameter, not changing the already set style.
In my opinion, the style
kwarg does not really have a place at all in these plotting (and this issue is symptom of that). Rather than
seq1.plot_sequence(style='blahblah')
seq2.plot_sequence(style='blahblah')
...
I think we should teach users/make examples with:
with plt.style.context('blahblah'): # Or something from sns!
seq1.plot_sequence()
seq2.plot_sequence()
(For more plots/sequences, note that this is also less repetitive) But this is obviously a bigger change and should be discussed further, cause I know you don't fully agree here.
I completely agree with all of the above. In general, taking the question further like you hinted at, what do we think the integration with Seaborn should be like? It's a question that was touched upon a long time ago; now, it sometimes feels weird to only integrate with matplotlib because it's not a library that I would say is very accessible to (or used by) our target audience. I feel that there's a combination of libraries that in academia would make sense to assume the combined use of: pandas, NumPy, (SciPy), and Seaborn.
Then the question becomes: how to integrate easily with Seaborn, and does that not in the end result in only Matplotlib stuff, because in a sense it's a wrapper, right?
Yes, so I would argue that seaborn and matplotlib are basically the same for the sake of this discussion. In the end, seaborn uses matplotlib as "backend". And matplotlib stays the unofficial default plotting library anyway, so for the current stage of this project, I don't really see an issue. On the medium-to-long term, if this becomes an issue for users or you want some fancy interactive plots with bokeh or so, we could look into a similar system as Pandas: https://pandas.pydata.org/docs/user_guide/visualization.html#plotting-backends
The other issue here is the balance between having "one simple function call for a beautiful plot by default" and integration with matplotlib and other libraries. thebeat isn't doing a bad job here, but I think there will always be some tension. I can see a couple of ways to deal with this:
- Tell the "advanced" users : "Not possible, if you want more styles, you'll have to plot things manually yourself." This risks annoying those users, but maybe they're the ones that can find the best workarounds.
- Make sure that plots are fully customizable (but as you can see above, issues not always obvious to spot!). This risks adding a lot of overhead, and still choosing between the "beautiful" and "don't change this" default parameter value in the function's API.
- Remove some easy shortcuts, in favor of teaching users in the examples/documentation how to use matplotlib (e.g., the style thing I suggested above). This risks making it harder to get started, I suppose.
- Duplicate the API into a lower-level minimal plotting and high-level single call. This risks being confusing.
- ... there are probably way more options
Always happy to brainstorm and chat when we both have time ;-)
Fixed in #99