materialsproject / pymatgen

Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.
https://pymatgen.org
Other
1.52k stars 867 forks source link

LaTeX errors in BSPlotter and BSDosplotter #707

Closed paulfons closed 7 years ago

paulfons commented 7 years ago

Silicon_bandstructure.ipynb.zip

<When reporting bugs/issues, please supply the following information. If this is a feature request, please simply state the requested feature.>

System

Summary

*Attempting to plot a simple band structure (Silicon) results in a matplot-related LaTeX error and no plot

Example code

I have attached a self-contained python notebook to this report that reproduces the error (it calculates the band structure of Silicon).

plot = plotter.get_plot(band_structure)

Error message

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-187-2455644d0a5f> in <module>()
      1 # show the plot
----> 2 plot = plotter.get_plot(band_structure)

/usr/lib64/python2.7/site-packages/pymatgen/electronic_structure/plotter.pyc in get_plot(self, zero_to_efermi, ylim, smooth, vbm_cbm_marker, smooth_tol)
    561             plt.ylim(ylim)
    562 
--> 563         plt.tight_layout()
    564 
    565         return plt

/usr/lib64/python2.7/site-packages/matplotlib/pyplot.pyc in tight_layout(pad, h_pad, w_pad, rect)
   1404 
   1405     fig = gcf()
-> 1406     fig.tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
   1407 
   1408 

/usr/lib64/python2.7/site-packages/matplotlib/figure.pyc in tight_layout(self, renderer, pad, h_pad, w_pad, rect)
   1751                                          renderer,
   1752                                          pad=pad, h_pad=h_pad, w_pad=w_pad,
-> 1753                                          rect=rect)
   1754 
   1755         self.subplots_adjust(**kwargs)

/usr/lib64/python2.7/site-packages/matplotlib/tight_layout.pyc in get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, pad, h_pad, w_pad, rect)
    351                                      subplot_list=subplot_list,
    352                                      ax_bbox_list=ax_bbox_list,
--> 353                                      pad=pad, h_pad=h_pad, w_pad=w_pad)
    354 
    355     if rect is not None:

/usr/lib64/python2.7/site-packages/matplotlib/tight_layout.pyc in auto_adjust_subplotpars(fig, renderer, nrows_ncols, num1num2_list, subplot_list, ax_bbox_list, pad, h_pad, w_pad, rect)
    128 
    129         tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots
--> 130                                 if ax.get_visible()])
    131         tight_bbox = TransformedBbox(tight_bbox_raw,
    132                                      fig.transFigure.inverted())

/usr/lib64/python2.7/site-packages/matplotlib/axes/_base.pyc in get_tightbbox(self, renderer, call_axes_locator)
   3821             bb.append(self._right_title.get_window_extent(renderer))
   3822 
-> 3823         bb_xaxis = self.xaxis.get_tightbbox(renderer)
   3824         if bb_xaxis:
   3825             bb.append(bb_xaxis)

/usr/lib64/python2.7/site-packages/matplotlib/axis.pyc in get_tightbbox(self, renderer)
   1093         ticks_to_draw = self._update_ticks(renderer)
   1094         ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,
-> 1095                                                                 renderer)
   1096 
   1097         self._update_label_position(ticklabelBoxes, ticklabelBoxes2)

/usr/lib64/python2.7/site-packages/matplotlib/axis.pyc in _get_tick_bboxes(self, ticks, renderer)
   1076         for tick in ticks:
   1077             if tick.label1On and tick.label1.get_visible():
-> 1078                 extent = tick.label1.get_window_extent(renderer)
   1079                 ticklabelBoxes.append(extent)
   1080             if tick.label2On and tick.label2.get_visible():

/usr/lib64/python2.7/site-packages/matplotlib/text.pyc in get_window_extent(self, renderer, dpi)
    965             raise RuntimeError('Cannot get window extent w/o renderer')
    966 
--> 967         bbox, info, descent = self._get_layout(self._renderer)
    968         x, y = self.get_unitless_position()
    969         x, y = self.get_transform().transform_point((x, y))

/usr/lib64/python2.7/site-packages/matplotlib/text.pyc in _get_layout(self, renderer)
    351         tmp, lp_h, lp_bl = renderer.get_text_width_height_descent('lp',
    352                                                          self._fontproperties,
--> 353                                                          ismath=False)
    354         offsety = (lp_h - lp_bl) * self._linespacing
    355 

/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in get_text_width_height_descent(self, s, prop, ismath)
    228             fontsize = prop.get_size_in_points()
    229             w, h, d = texmanager.get_text_width_height_descent(s, fontsize,
--> 230                                                                renderer=self)
    231             return w, h, d
    232 

/usr/lib64/python2.7/site-packages/matplotlib/texmanager.pyc in get_text_width_height_descent(self, tex, fontsize, renderer)
    674         else:
    675             # use dviread. It sometimes returns a wrong descent.
--> 676             dvifile = self.make_dvi(tex, fontsize)
    677             dvi = dviread.Dvi(dvifile, 72 * dpi_fraction)
    678             try:

/usr/lib64/python2.7/site-packages/matplotlib/texmanager.pyc in make_dvi(self, tex, fontsize)
    421                      'string:\n%s\nHere is the full report generated by '
    422                      'LaTeX: \n\n' % repr(tex.encode('unicode_escape')) +
--> 423                      report))
    424             else:
    425                 mpl.verbose.report(report, 'debug')

RuntimeError: LaTeX was not able to process the following string:
'lp'
Here is the full report generated by LaTeX: 

Suggested solution (if any)

Files (if any)

<If input files are needed to reproduce the error, please provide either links (e.g., Dropbox or GDrive) for large files or simply paste the file below for small files.>

<contents of file 1>

The attached zip archive contains a python notebook that carries out a simple band structure calculation on Silicon that generates the (matplotlib related) LaTeX errors.
paulfons commented 7 years ago

I discovered that this error occurred for an older opensuse version 42.1, I will upgrade to opensuse 42.2 to see if the error still exists and file a new issue if needed.