On 10/28/10 11:50 AM, John Hunter wrote:
> On Thu, Oct 28, 2010 at 1:11 PM, Christopher Barker
>>> You can set these env variables within your code, before import of
>>> matplotlib via os.environment.

> The MPLCONFIGDIR tells mpl where to find the config file.  It's hard
> to read the config, no matter how pythonic it is,  if you don't know
> where it is.

OK -- so that does need to be set as the first part of the process.

>  Once the config file (matplotlibrc) is located  you can
> set the datapath with the  'datapath' parameter so you don't need
> MATPLOTLIBDATA (which is only used if datapath is not set).

So the fontcache will be put/found there? That would solve part of 
Russell's (and my) issue.

> We could use command line args, but mpl is a library and shouldn't
> really be using them...  Arguably we are already doing too much in the
> way of command line args.

I agree -- command line args are not the way to go.

On 10/28/10 12:46 PM, Russell E. Owen wrote:

> It's an interesting question. You can't call a matplotlib function to do
> it because it has to happen before matplotlib is loaded. I suppose there
> could be a configuration package to perform the operation.

I actually like that idea. It could even do a bit more, like have the 
matplotlib.use() function, and who knows how many others.

I've never liked the .matplotlibrc approach -- it makes great sense for 
an interactive environment, but not so much for embedding MPL in other 
apps, for all the reason's Russell has laid out.

If there was a mplconfig module that you could import first, and have 
functions in there where you could set all the defaults the way tyou 
like them, it would be easier to make self-contained MPL apps that 
didn't step on each-others toes.

> * The font cache uses absolute paths.

perhaps that could be fixed -- how are parameters like that stored now? 
If it was an attribute of some object, it could be made a property that 
resolved the path is some nifty way. Or, if there were a mplconfig 
module, it could figure out the absolute path for the font cache at run 
time.

> * Where to put it?
>
> I had hoped to put it in the bundled application itself, so that it
> would be thrown out when the application was thrown out.

I think the official way to do it on OS-X is to put it in 
~/Library/Application Support. However, I don't now how that gets 
cleaned up -- if ever!

> I'd like to avoid generating a new MPLCONFIGDIR directory for every
> version of my application (or every version of matplotlib).

I suppose, like for any application configuration, you'd want a new 
version to check the config, and clean it out if it is for an old 
version (or, even better, update for the new version, but that's a lot 
of work)

> An alternative is to just keep using the default MPLCONFIGDIR
> (~/.matplotlib) and put up with the risk of a matplotlibrc file doing
> bad things. That's my plan for now since I know few users who bother to
> set exotic things in their matplotlibrc files, and my application
> already explicitly set the important settings.

I've gotten away with that as well, but I still don't like it!

Is is possible for MPL to read from one place, but write to another? 
Doesn't that happen already for when MPL first starts up and doesn't 
have anything?

And it sounds like the fontcache and rc file don't NEED to be in teh 
same place -- they probably shouldn't be for this type of use.

-Chris

-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

chris.bar...@noaa.gov

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to