Matt Funk, on 2011-04-07 16:52,  wrote:
> Hi,
> i am farily new to matplotlib so my question might be fairly basic. I would 
> like to be able to set certain default values at the beginning of my script. 
> The way i did this with the other values is via changing the value stored in 
> rcparams. So something like:
> import matplotlib.pyplot as mpl
> mpl.rcParams['lines.markersize'] = 20
> 
> But i would like to set the markerfacecolor in such a way but it is not 
> included in rcParams. I would really like to avoid setting it in each 
> individual plot call. 
> 
> Is there a way to change the default at the start of the script?

Hi Matt,

this depends on how you're plotting. 

If you're just using plt.plot - it defers to cycling through the
rcParams['axes.color_cycle'] - so just set that to one value
before starting your plots..

old_color_cycle = rcParams['axes.color_cycle']
rcParams['axes.color_cycle'] = 'purple' # cue Gogol Bordello
plt.figure()
ax = plt.subplot(111)

ax.plot(range(10),'o', markersize=40)
ax.plot(np.random.rand(10),'o', markersize=40)
ax.plot(np.random.rand(10)*10,'o', markersize=40)

# restore color_cycle just for this axes
ax._get_lines.set_color_cycle(old_color_cycle)
ax.plot(range(20,30), range(10),'o', markersize=40)
ax.plot(range(20,30), np.random.rand(10),'o', markersize=40)
ax.plot(range(20,30), np.random.rand(10)*10,'o', markersize=40)

# restore old cycle for all new axes
rcParams['axes.color_cycle'] = old_color_cycle 
--

If, on the other hand, you're using scatter, there isn't
currently a way of doing the same, since scatter just uses 'b' as
the default parameter for color.

This should probably be changed to act the same way plot does,
but that isn't currently implemented. This would be a good first 
patch for a newcomer -- and would make matplotlib more consistent.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

Attachment: signature.asc
Description: Digital signature

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to