1

I'm having trouble getting matplotlib plots to appear in front of my other windows - this is apparently a macosx backend problem. However, after making the following changes in ~/.matplotlib/matplotlibrc.py:

#backend      : macosx
backend : TkAgg

I run this command in python

import matplotlib            
print matplotlib.rcParams['backend']

and it returns:

MacOSX
[Finished in 4.1s]

What's going wrong? Or rather, how do I get plots to appear in front of other windows?

Other information:

osx 10.9 (mavericks) python --version -> Python 2.7.9 :: Anaconda 2.2.0 (x86_64) using sublime text 3, build 3083

2 Answers 2

1

As outlined in the documentation the rc file has no .py extension:

  • On Linux, it looks in .config/matplotlib/matplotlibrc [...]
  • On other platforms, it looks in .matplotlib/matplotlibrc.

In fact it does not have python syntax but rather uses a yaml-like dictionary structure. So it is likely that matplotlib does not use your file at all.

You can use this:

import matplotlib
matplotlib.matplotlib_fname()

to figure out which configuration file matplotlib uses (and by that confirm that matplotlib acutally reads the file that you want to be read).

Sign up to request clarification or add additional context in comments.

2 Comments

Config file is being read after removing the .py extension. I still "cmd tab" to get to the image, but at least they're not hiding now. Thanks!
As per your window focus problem, this seems to be relevant: github.com/matplotlib/matplotlib/issues/665 Maybe updateing matplotlib will help
0

What worked for me was putting the following in the top of your module where you want to use matplotlib:

import matplotlib
matplotlib.use('TkAgg')

1 Comment

Well, I guess I'd really like a more permanent solution; I don't understand why altering matplotlibrc.py isn't changing the backend...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.