Closed computron closed 10 years ago
Try reinstalling matplotlib?
Shyue Ping
On July 5, 2014 at 6:30:09 PM, Anubhav Jain (notifications@github.com) wrote:
I am trying to plot band structures using the following code:
from pymatgen import MPRester from pymatgen.electronic_structure.plotter import BSPlotter
if name == "main": MAPI_KEY = None # You must change this to your Materials API key! (or set MAPI_KEY env variable) MP_ID = "mp-19017" # You must change this to the mp-id of your compound of interest
mpr = MPRester(MAPI_KEY) # object for connecting to MP Rest interface
my_bs = mpr.get_bandstructure_by_material_id(MP_ID)
BSPlotter(my_bs).show()
Something seems to be wrong with my matplotlib configuration and the code trips over the tight_layout, giving me the following error:
tight_layout : falling back to Agg renderer
Traceback (most recent call last):
File "/Users/ajain/Documents/code_testing/aj_scratch/aj_play/scratch.py", line 12, in
I can turn off tight layout (manually commenting it out), and the main portion of the band structure plot renders fine, but the x-labels and y-labels do not render and I get the following error:
Traceback (most recent call last): File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, _args, _kwargs) File "/Library/Python/2.7/site-packages/matplotlib/figure.py", line 898, in draw func(_args) File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, args, _kwargs) File "/Library/Python/2.7/site-packages/matplotlib/axes.py", line 1997, in draw a.draw(renderer) File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, _args, _kwargs) File "/Library/Python/2.7/site-packages/matplotlib/axis.py", line 1042, in draw ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw, renderer) File "/Library/Python/2.7/site-packages/matplotlib/axis.py", line 993, in _get_tick_bboxes extent = tick.label1.get_window_extent(renderer) File "/Library/Python/2.7/site-packages/matplotlib/text.py", line 747, in get_window_extent bbox, info = self._get_layout(self._renderer) File "/Library/Python/2.7/site-packages/matplotlib/text.py", line 309, in _get_layout ismath=ismath) File "/Library/Python/2.7/site-packages/matplotlib/backends/backend_macosx.py", line 153, in get_text_width_height_descent renderer=self) File "/Library/Python/2.7/site-packages/matplotlib/texmanager.py", line 608, in get_text_width_height_descent page = iter(dvi).next() File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 65, in iter have_page = self._read() File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 121, in _read self._dispatch(byte) File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 209, in _dispatch self._fnt_def(k, c, s, d, a, l, n) File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 362, in _fnt_def tfm = _tfmfile(n[-l:]) File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 872, in _tfmfile return _fontfile(texname, Tfm, '.tfm', _tfmcache) File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 862, in _fontfile filename = find_tex_file(texname + suffix) File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 843, in find_tex_file stderr=subprocess.PIPE) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 679, in init errread, errwrite) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1228, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory Traceback (most recent call last): File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, _args, _kwargs) File "/Library/Python/2.7/site-packages/matplotlib/figure.py", line 898, in draw func(_args) File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, args, _kwargs) File "/Library/Python/2.7/site-packages/matplotlib/axes.py", line 1997, in draw a.draw(renderer) File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, _args, _kwargs) File "/Library/Python/2.7/site-packages/matplotlib/axis.py", line 1042, in draw ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw, renderer) File "/Library/Python/2.7/site-packages/matplotlib/axis.py", line 993, in _get_tick_bboxes extent = tick.label1.get_window_extent(renderer) File "/Library/Python/2.7/site-packages/matplotlib/text.py", line 747, in get_window_extent bbox, info = self._get_layout(self._renderer) File "/Library/Python/2.7/site-packages/matplotlib/text.py", line 309, in _get_layout ismath=ismath) File "/Library/Python/2.7/site-packages/matplotlib/backends/backend_macosx.py", line 153, in get_text_width_height_descent renderer=self) File "/Library/Python/2.7/site-packages/matplotlib/texmanager.py", line 608, in get_text_width_height_descent page = iter(dvi).next() File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 65, in iter have_page = self._read() File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 121, in _read self._dispatch(byte) File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 209, in _dispatch self._fnt_def(k, c, s, d, a, l, n) File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 362, in _fnt_def tfm = _tfmfile(n[-l:]) File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 872, in _tfmfile return _fontfile(texname, Tfm, '.tfm', _tfmcache) File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 862, in _fontfile filename = find_tex_file(texname + suffix) File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 843, in find_tex_file stderr=subprocess.PIPE) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 679, in init errread, errwrite) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1228, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory
— Reply to this email directly or view it on GitHub.
Ok I didn't get this working (e.g. even after reinstalling matplotlib) but I'm pretty sure this is something in my local matplotlib installation rather than pymatgen. Closing the issue
Btw I finally solved this - the issue has to do with matplotlib not finding LaTeX. The package installer for Mac LaTeX (MacTeX) installs the latex executables in /usr/texbin, which gets added to the PATH. However PyCharm doesn't see this as part of its path, so it can't find LaTeX and can't plot any chart involving LaTeX. If you set your PyCharm run environment to include /usr/texbin all is well
I am trying to plot band structures using the following code:
Something seems to be wrong with my matplotlib configuration and the code trips over the tight_layout, giving me the following error:
I can turn off tight layout (manually commenting it out), and the main portion of the band structure plot renders fine, but the x-labels and y-labels do not render and I get the following error: