If I run it as python code (e.g. %run namefile.py inside ipython) it works and shows a bar chart on the screen; if I run it inside sage or sage -python namefile.py, then I see no result. I presume that Sage does some wrapping of matplotlib's output that interacts with the plotting?