|
From: John H. <jd...@gm...> - 2007-12-05 15:19:06
|
On Dec 5, 2007 6:38 AM, S=F8ren Nielsen <sor...@gm...> wrot= e: > Hi, > > Is it possible to expand the colorcycle that matplotlib uses by default? > > in axes.py, class _process_plot_var_args, def _clear_color_cycle(self) It > seems that self.colors are hardcoded to be self.colors =3D > ['b','g','r','c','m','y','k'] ... is there a way to extend this? (Without > changing the matplotlib code directly) I want to be able to extend it by = ex. > dashed lines or others.. i sometimes have a large number of plots to do, = and > the 7 default plot colors are not enough... > > I know I could manually make a handler in my program to handle the colors > when I plot... but it would seem nicer if I could just pass a list of plo= t > colors to matplotlib. I just made a chance in svn to expose the default color list. Here is an ipython session that shows how to use it: In [1]: import matplotlib.axes as mplaxes In [2]: x, y =3D rand(2,100) In [3]: plot(x, y, 2*x, 2*y) Out[3]: [<matplotlib.lines.Line2D instance at 0x8f2dc8c>, <matplotlib.lines.Line2D instance at 0x8f2dd6c>] In [4]: mplaxes._process_plot_var_args.defaultColors =3D ['red', 'darkslategray', 'wheat'] In [5]: clf() In [6]: plot(x, y, 2*x, 2*y) Darren, we might want to expose this in the matplotlib.conf, but perhaps is it a rare enough request that it is enough to let people tweak it manually when needed. The only thing that is a bit ugly is that Axes._process_plot_var_args has the leading underscore indicating it should not be used outside of mpl, but this is easy enough to remedy... JDH |