Giter VIP home page Giter VIP logo

Comments (3)

shyuep avatar shyuep commented on May 19, 2024

Try reinstalling matplotlib?

Shyue Ping

On July 5, 2014 at 6:30:09 PM, Anubhav Jain ([email protected]) 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
BSPlotter(my_bs).show()
File "/Users/ajain/Documents/code_matgen/pymatgen_repo/pymatgen/electronic_structure/plotter.py", line 508, in show
plt = self.get_plot(zero_to_efermi, ylim, smooth)
File "/Users/ajain/Documents/code_matgen/pymatgen_repo/pymatgen/electronic_structure/plotter.py", line 492, in get_plot
plt.tight_layout()
File "/Library/Python/2.7/site-packages/matplotlib/pyplot.py", line 1055, in tight_layout
fig.tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad)
File "/Library/Python/2.7/site-packages/matplotlib/figure.py", line 1414, in tight_layout
pad=pad, h_pad=h_pad, w_pad=w_pad)
File "/Library/Python/2.7/site-packages/matplotlib/tight_layout.py", line 117, in auto_adjust_subplotpars
tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots])
File "/Library/Python/2.7/site-packages/matplotlib/axes.py", line 8362, in get_tightbbox
bb_xaxis = self.xaxis.get_tightbbox(renderer)
File "/Library/Python/2.7/site-packages/matplotlib/axis.py", line 1008, in get_tightbbox
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 300, in _get_layout
ismath=False)
File "/Library/Python/2.7/site-packages/matplotlib/backends/backend_agg.py", line 188, 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

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.

from pymatgen.

computron avatar computron commented on May 19, 2024

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

from pymatgen.

computron avatar computron commented on May 19, 2024

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

from pymatgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.