[Matplotlib-devel] Changing rcParams locally, on the fly

Drain, Theodore R (392P) theodore.r.drain at jpl.nasa.gov
Wed Mar 9 10:30:33 EST 2016


It's not quite what you want (no color cycling), but the style system we implemented knows how to apply itself to existing figures, axes, artists, etc.  It makes it pretty easy to modify drawing attributes after the figure is drawn and see the affects.  For example you can do this to modify a figure after it's on the screen:

smgr.set( fig, { "bgColor" : "black",
                 "fgColor" : "white",
                 "text.font.scale" : 1.25 } )

Repository: https://github.com/nasa/mplStyle


________________________________________
From: Matplotlib-devel [matplotlib-devel-bounces+theodore.drain=jpl.nasa.gov at python.org] on behalf of Lucas Verney [lucas at phyks.me]
Sent: Monday, February 29, 2016 9:50 AM
To: Benjamin Root; Phyks
Cc: matplotlib development list
Subject: Re: [Matplotlib-devel] Changing rcParams locally, on the fly

Ok, I was not expecting matplotlib to work this way. I was actually
thinking it was storing the drawing commands in some buffer, and was
actually doing the render when needed.

For my use case, I think I should better write a buffer on top of
matplotlib and only call it in the end, when I am actually drawing the
graph.

Thanks

Le 29/02/2016 18:33, Benjamin Root a écrit :
> I should also note, that it is possible to change the color cycle after an
> axes is created (although, now it is called the prop_cycle), using
> ax.set_prop_cycle(). Keep in mind that any plots that have already been
> made are unaffected by changing the property cycle because they have
> already had their properties assigned.
>
> On Mon, Feb 29, 2016 at 12:31 PM, Benjamin Root <ben.v.root at gmail.com>
> wrote:
>
>> There is the context manager approach, but it must be utilized prior to
>> axes creation. For the most part, any usage of the rcParams happen at
>> creation time of the relevant artist. So, while you could update the color
>> cycle prior to creating an axes but after the figure creation, changing the
>> default figure size would be useless at that point since the figure is
>> already made.
>>
>> There might be some push in the future to defer rcParam evaluation closer
>> to draw time (traitlet integration), but I wouldn't bet on it happening any
>> time soon, and it probably wouldn't do what you need in any case.
>>
>> Ben Root
>>
>>
>> On Mon, Feb 29, 2016 at 12:03 PM, Phyks <spam+matplotlib at phyks.me> wrote:
>>
>>> Hi,
>>>
>>> Is there a way to change locally the rcParams, for a specific figure after
>>> it has been created?
>>>
>>> I know about the rcParams setting (for global settings) and the with
>>> statement construction, but this requires to be done before the figure was
>>> created, and I need to change the settings on an already existing figure
>>> (in
>>> particular color cycler).
>>>
>>> Thanks
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://matplotlib.1069221.n5.nabble.com/Changing-rcParams-locally-on-the-fly-tp46813.html
>>> Sent from the matplotlib - devel mailing list archive at Nabble.com.
>>> _______________________________________________
>>> Matplotlib-devel mailing list
>>> Matplotlib-devel at python.org
>>> https://mail.python.org/mailman/listinfo/matplotlib-devel
>>>
>>
>>
>
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel at python.org
https://mail.python.org/mailman/listinfo/matplotlib-devel


More information about the Matplotlib-devel mailing list