New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: allow plotting libraries to easily hook into pandas #5489
Comments
prettyplolib also has a dependencies on brewer2mpl. I'm not so sure about this: the lib changes mpl.rcParams directly (and some on import -> so simple importing prettyplotlib will change other unrelated matplotlib plots!) and this means that you can't use your own style anymore. So, an example which I think won't work anymore is this: import matplotlib.pyplot as plt
from pandas import *
from numpy.random import randn
ts = Series(randn(1000), index=date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
# plots normal and if this is implemented "nicer" plots
ts.plot()
plt.show()
# prints currently a xkcdified plot, but probably won't work if the plot function sets other
# mpl.rcParams *after* the `xkcd()` context manager sets the mpl.rcParams for the
# xkcd version
with plt.xkcd():
ts.plot()
plt.show() There are also other libs like prettyplotlib out there, which wrap matplotlib to produce nicer plots: [EDIT: It would be nice if they have a way to us there own styling system without getting styles from whatever system you choose.] There is also functions around, which style already existing matplotlib plots or set some "nicer" defaults:
|
Okay, that's a very good point, let's keep it under an optional argument (that's disabled by default). We should be guarding mpl imports altogether so that matplotlib is not imported unless (and until) the user calls for plotting. Bottom line, I'd like pandas to have better plotting output because the default styles are not great and most people (including me) want to be able to not think about it. Other notes:
|
If you "just" want to have a nice plotting:
(which shows that just importing prettyprintlib will change plotting for unrelated plots -> IMO a bug: olgabot/prettyplotlib#15 ) What could work is something like this (without any tests that it compiles...): prettyplotlib_rcParams = {}
# hack, it would be nice to use a prettyplotlib.rc_context() -> see bugreport
with mpl.rc_context():
import prettyplotlib
prettyplotlib_rcParams.update(mpl.rcParams)
....
def _get_plotting_styles():
name = [get the options system to spit out which styles should be used]
if name in ["default", "prettyplotlib"]:
return prettyplotlib_rcParams
else:
return {}
def plot(...):
styles = _get_plotting_styles()
with mpl.rc_context(rc=styles):
[current ploting...] |
Alternatively a settings in I've been struggling with what pandas should be doing to support all the awesome plotting libraries sprouting up. (I'd add Bokeh and Vincent to the ones @JanSchulz listed). Providing the data structure and letting each library build off that is one thing. But the style of |
@jtratner How do you see it different to the current Regarding yhat's ggplot, this is not impossible, because, apart from the new syntax (which emulates matplotlib calls), it just uses some rcParams calls to define it's style (https://github.com/yhat/ggplot/blob/master/ggplot/themes/theme_gray.py), The You also have |
Hello, prettyplotlib developer here. I could also adjust the library so it If there's a toggle like Olga Botvinnik On Tue, Nov 12, 2013 at 10:02 AM, Tom Augspurger
|
@jorisvandenbossche the theming in ggplots PR yhat/ggpy#75 will use more than |
Either way with ggplot2 or prettyplotlib styling, I think the pandas Olga Botvinnik On Tue, Nov 12, 2013 at 10:20 AM, JanSchulz notifications@github.comwrote:
|
I merged #3112 originally since the default mpl color theme is so horrible. However, It's off by It may be possible to Note that the pandas' deps have exploded in the last 6-9 months and increasingly support for multiple Would it be possible to integrate new styles by using the existing style mechanism rather then introducing |
@y-p I agree with you here (and that's why I changed the title of this PR today). I want to make it easy to plug into pandas plotting. At the least, we should probably enable the What I'd like to come out of this is a more abstracted plotting, maybe changing pandas/tools/plotting to be a set of static methods on a class that then gets looked up by NDFrame (and could then be subclassed by plotting libraries). Alternatively could just allow monkey patching. @olgabot would it be enough to just have an init method that changed the default color scheme? (maybe monkey patching mpl_style). Or do you actually need to use prettyplotlib's methods? |
To make all mpl changes side effect free: with mpl.rc_context():
mpl.rcParams[...] = ...
[or importing prettyplotlib or whatever...]
[plotting commands as before] There is also |
I think this may be geting off topic for this post, but it's very |
The FYI @y-p I'm having trouble installing matplotlib on my OS X Mavericks Olga Botvinnik On Thu, Nov 14, 2013 at 3:00 AM, Jeff Tratner notifications@github.comwrote:
|
if the ggplot.py people get their community-building act together I can totally see it |
@jtratner , it looks like the libs have decided for themselves and they are consuming Can we close? |
Fine with me, though it would be nice if plot() looked better by default... not a big deal though. |
ok, better how? |
Right now not all parameters can be specified by a rcParams file to Olga Botvinnik On Sat, Jan 25, 2014 at 11:30 AM, y-p notifications@github.com wrote:
|
@olgabot, we did add an option to activate mpl styles which is a substantial improvement on I thought prettyplotlib does substantially more then just color schemes, and we did end up Maybe the scope of the issue is unclear, but re making ggplot/seaborn/perttyplotlib There's no shame in being a substrate. :) On making pandas defaults prettier, we can have a new issue with more focused scope. |
At PyData I was introduced to this great library that wraps matplotlib called prettyplotlib by @olgabot and it was used to good effect in @twiecki's presentation on PyMC3.
I want to incorporate this into pandas - it would be a great improvement and a light dep for the library.
@olgabot said she was interested in working on a PR to incorporate it, so going to track from this issue.
The text was updated successfully, but these errors were encountered: