Comments (3)
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.
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.
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)
- ChemEnv unable to identify the neighboring environments HOT 5
- Default settings of `Structure.relax()` fails to synchronize tensor locations (CPU/GPU) on GPU-enabled environments HOT 1
- Unexpected Tokenizing error when using `parse_lammps_dumps`
- The inconsistent results when finding the transformatoin matrix between two space groups using StructureMatcher and Bilbao Crystallographic Server IDENTIFY GROUP. HOT 5
- Duplicate atom generated with Structure.from_spacegroup
- KPOINTS_OPT based one-shot calculation input files generation and the corresponding post-processing. HOT 3
- ValueError:dictionary update sequence element #0 has length 1; 2 is required HOT 2
- create a hcp mg grain boundary mgΣ7[0001](0001) too many values to unpack (expected 3) HOT 2
- Spacegroup P212121 does not give a valid pointgroup
- New pymatgen version HOT 10
- Numerical instability in lattice matrix operations : get_slabs / StructureMatcher / _cart_dists
- `typing_extension` imported at run time causing ImportError HOT 4
- OptimadeRester HOT 14
- Overlayed subplots from `BSPlotterProjected.get_projected_plots_dots()` and `get_projected_plots_dots_patom_pmorb()` HOT 1
- `atom_site_label` in CIF file are not unique HOT 10
- CrystalNN gives incorrect result for simple aromatic ring HOT 13
- ChemEnv unable to identify the environments of supercell HOT 7
- Atom labels in CIF file are silently rewritten by CifWriter HOT 6
- Collect possible issues might come with Python 3.12
- Incompatibility Issue with ALGO Parameter in Incar and Vasprun Classes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
ð Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â€ïž Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pymatgen.