From: Tony Yu <ts...@gm...> - 2013-07-21 07:22:26
|
On Sat, Jul 20, 2013 at 9:10 PM, David P. Sanders < dps...@ci...> wrote: > > > > On Sat, Jul 20, 2013 at 8:48 PM, Chris Beaumont <bea...@ha...>wrote: > >> >> <snip> > However, default tweaking need not be painful. As has been mentioned, a >> first step would be an easier way to change a whole set of rcParams: >> something like mpl.set_style('style-name'). As long as one style is >> 'classic', users can keep the current style for as long as they want. It's >> a one line fix, and could even be rcParams-settable. >> > > This is already implemented! The problem is, it's hidden away in the > mpltools toolkit: > > http://tonysyu.github.io/mpltools/ > > which nobody seems to know about or use, which is a great shame, since > it's first class -- great job, Tony! > > The first example there is: > > >>> from mpltools import style>>> style.use('ggplot') > > and then the plot is suddenly jaw-droppingly beautiful! > > This is achieved with style files which just have lists of matplotlib > params like this: > > patch.linewidth = 0.5 > patch.facecolor = '#348ABD' # blue > patch.edgecolor = '#EEEEEE' > patch.antialiased = True > > These are parsed using the ConfigObj package (this package parses config > files of this type). > > Somebody (Chris?) tweeted something about the Vega package earlier: > http://trifacta.github.io/vega/ > > They seem to have these kind of things solved already (disclaimer: I only > browsed briefly their site) using JSON, but actually Tony's approach seems > like a winner. > > mpltools may be installed with > > > pip install ConfigObj > > pip install mpltools > > [For some reason the dependency on ConfigObj is not registered in > mpltools. Tony, are you the packager?] > I'm not really sure why the configobj dependency doesn't resolve properly. As they say: pull requests are welcome. ;) This is all *crying out* to be dropped straight into matplotlib proper! > Here's a PR to add the style sheets from mpltools: https://github.com/matplotlib/matplotlib/pull/2236 (using matplotlib's parser instead of ConfigObj) Cheers! -Tony > David > > |