Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/131.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matplotlib Jupyter 5、Python 3.6和Latex_Matplotlib_Jupyter Notebook_Python 3.6 - Fatal编程技术网

Matplotlib Jupyter 5、Python 3.6和Latex

Matplotlib Jupyter 5、Python 3.6和Latex,matplotlib,jupyter-notebook,python-3.6,Matplotlib,Jupyter Notebook,Python 3.6,我想用Jupyter笔记本记录我的研究成果。以前,我使用了一个带有Python2.7和Jupyter4的笔记本,没有任何问题。得益于Anaconda,我最近一直在尝试使用Jupyter 5和Python 3.6。但是,当我试图显示热图时,我收到一个错误 使用简单折线图编辑 #--编码:utf-8-- %matplotlib内联 from future.builtins import * from future.utils import (viewitems, viewkeys, viewvalu

我想用Jupyter笔记本记录我的研究成果。以前,我使用了一个带有Python2.7和Jupyter4的笔记本,没有任何问题。得益于Anaconda,我最近一直在尝试使用Jupyter 5和Python 3.6。但是,当我试图显示热图时,我收到一个错误

使用简单折线图编辑 #--编码:utf-8-- %matplotlib内联

from future.builtins import *
from future.utils import (viewitems, viewkeys, viewvalues)

import sys
from os import (environ, path)
from collections import OrderedDict

# Numpy and related libraries
import numpy as np
import scipy
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import (linalg, stats)
from matplotlib import (cm, colors, ticker)
from mpl_toolkits import axes_grid1

from IPython.display import (display, )

# Display full list of DataFrame
pd.set_option("display.max_rows", None)
pd.set_option("display.max_columns", None)
pd.set_option("display.notebook_repr_html",True)

# Update parameters for matplotlib
params = {"text.usetex": True,
          "text.latex.unicode": True,
          "axes.unicode_minus": True,
         }
plt.rcParams.update(params)
pd.set_option("precision", 2)

# This sets reasonable defaults for font size for
# a figure that will go in a paper
sns.set_context("paper")

# Set the font to be serif, rather than sans
sns.set(font='serif')

# Make the background white, and specify the
# specific font family
sns.set_style("white",
              {
                  "font.family": "serif",
                  "font.serif": ["Times New Roman", "Palatino", "serif"],
                  "font.sans-serif": ["Arial", "Helvetica"],
                  "font.monospace": ["Courier New", "Courier"]
              })
sns.set_style("ticks")
models = ("calpha", "caside", "ncsc", "polar")

# Simple test case
data = np.random.random(10)
data = pd.Series(data=data, dtype=np.float)

fig, ax = plt.subplots()
data.plot(ax=ax, title="Linear randomness", kind="line", use_index=True)
ax.set_xlabel(r"Time (${\mu}$s)")
ax.set_ylabel("r.m.s.d. (Å)")
ax.xaxis.set_major_locator(ticker.MultipleLocator(0.1))
ax.xaxis.set_major_formatter(ticker.StrMethodFormatter("{x:.0f}"))
ax.yaxis.set_major_formatter(ticker.StrMethodFormatter("{x:.1f}"))
ax.grid()
fig.tight_layout()
但是,我收到以下错误:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-5-727fbc0d285c> in <module>()
     10 ax.yaxis.set_major_formatter(ticker.StrMethodFormatter("{x:.1f}"))
     11 ax.grid()
---> 12 fig.tight_layout()

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/figure.py in tight_layout(self, renderer, pad, h_pad, w_pad, rect)
   2005         kwargs = get_tight_layout_figure(
   2006             self, self.axes, subplotspec_list, renderer,
-> 2007             pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
   2008         self.subplots_adjust(**kwargs)
   2009 

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/tight_layout.py in get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, pad, h_pad, w_pad, rect)
    349                                      subplot_list=subplot_list,
    350                                      ax_bbox_list=ax_bbox_list,
--> 351                                      pad=pad, h_pad=h_pad, w_pad=w_pad)
    352 
    353     if rect is not None:

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/tight_layout.py in auto_adjust_subplotpars(fig, renderer, nrows_ncols, num1num2_list, subplot_list, ax_bbox_list, pad, h_pad, w_pad, rect)
    127             continue
    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,

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/tight_layout.py in <listcomp>(.0)
    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())

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/axes/_base.py in get_tightbbox(self, renderer, call_axes_locator)
   3952 
   3953         if self.title.get_visible():
-> 3954             bb.append(self.title.get_window_extent(renderer))
   3955         if self._left_title.get_visible():
   3956             bb.append(self._left_title.get_window_extent(renderer))

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/text.py in get_window_extent(self, renderer, dpi)
    968             raise RuntimeError('Cannot get window extent w/o renderer')
    969 
--> 970         bbox, info, descent = self._get_layout(self._renderer)
    971         x, y = self.get_unitless_position()
    972         x, y = self.get_transform().transform_point((x, y))

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/text.py in _get_layout(self, renderer)
    352         tmp, lp_h, lp_bl = renderer.get_text_width_height_descent('lp',
    353                                                          self._fontproperties,
--> 354                                                          ismath=False)
    355         offsety = (lp_h - lp_bl) * self._linespacing
    356 

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in get_text_width_height_descent(self, s, prop, ismath)
    224             fontsize = prop.get_size_in_points()
    225             w, h, d = texmanager.get_text_width_height_descent(
--> 226                 s, fontsize, renderer=self)
    227             return w, h, d
    228 

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/texmanager.py in get_text_width_height_descent(self, tex, fontsize, renderer)
    602             dvifile = self.make_dvi(tex, fontsize)
    603             with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 604                 page = next(iter(dvi))
    605             # A total height (including the descent) needs to be returned.
    606             return page.width, page.height + page.descent, page.descent

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/dviread.py in __iter__(self)
    247         """
    248         while True:
--> 249             have_page = self._read()
    250             if have_page:
    251                 yield self._output()

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/dviread.py in _read(self)
    308         while True:
    309             byte = ord(self.file.read(1)[0])
--> 310             self._dtable[byte](self, byte)
    311             if byte == 140:                         # end of page
    312                 return True

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/dviread.py in wrapper(self, byte)
    164             if state is not None and self.state != state:
    165                 raise ValueError("state precondition failed")
--> 166             return method(self, *[f(self, byte-min) for f in get_args])
    167         if max is None:
    168             table[min] = wrapper

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/dviread.py in _fnt_def(self, k, c, s, d, a, l)
    455     @dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    456     def _fnt_def(self, k, c, s, d, a, l):
--> 457         self._fnt_def_real(k, c, s, d, a, l)
    458 
    459     def _fnt_def_real(self, k, c, s, d, a, l):

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/dviread.py in _fnt_def_real(self, k, c, s, d, a, l)
    460         n = self.file.read(a + l)
    461         fontname = n[-l:].decode('ascii')
--> 462         tfm = _tfmfile(fontname)
    463         if tfm is None:
    464             if six.PY2:

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/dviread.py in _tfmfile(texname)
   1074 
   1075 def _tfmfile(texname):
-> 1076     return _fontfile(texname, Tfm, '.tfm', _tfmcache)
   1077 
   1078 

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/dviread.py in _fontfile(texname, class_, suffix, cache)
   1063         pass
   1064 
-> 1065     filename = find_tex_file(texname + suffix)
   1066     if filename:
   1067         result = class_(filename)

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/dviread.py in find_tex_file(filename, format)
   1043     # https://github.com/matplotlib/matplotlib/issues/633
   1044     pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE,
-> 1045                             stderr=subprocess.PIPE)
   1046     result = pipe.communicate()[0].rstrip()
   1047     matplotlib.verbose.report('find_tex_file result: %s' % result,

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
    707                                 c2pread, c2pwrite,
    708                                 errread, errwrite,
--> 709                                 restore_signals, start_new_session)
    710         except:
    711             # Cleanup if the child failed starting.

/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
   1342                         if errno_num == errno.ENOENT:
   1343                             err_msg += ': ' + repr(err_filename)
-> 1344                     raise child_exception_type(errno_num, err_msg, err_filename)
   1345                 raise child_exception_type(err_msg)
   1346 

FileNotFoundError: [Errno 2] No such file or directory: 'kpsewhich': 'kpsewhich'
---------------------------------------------------------------------------
FileNotFoundError回溯(最近一次调用上次)
在()
10 ax.yaxis.set\u major\u格式化程序(ticker.StrMethodFormatter(“{x:.1f}”))
11 ax.grid()
--->图12紧_布局图()
/紧密布局中的opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/figure.py(self、renderer、pad、h_-pad、w_-pad、rect)
2005 kwargs=获得紧密布局图(
2006 self,self.axes,subplotspec_列表,渲染器,
->2007 pad=pad,h_pad=h_pad,w_pad=w_pad,rect=rect)
2008年自我调整子地块(**kwargs)
2009
/获取紧密布局图中的opt/homebrew/anaconda3/envs/mda dev/lib/python3.6/site-packages/matplotlib/tight\u layout.py(图、轴列表、子页面规范列表、渲染器、焊盘、h\u焊盘、w\u焊盘、rect)
349子地块列表=子地块列表,
350 ax_bbox_列表=ax_bbox_列表,
-->351焊盘=焊盘,h焊盘=h焊盘,w焊盘=w焊盘)
352
353如果rect不是None:
/自动调整子地块PAR中的opt/homebrew/anaconda3/envs/mda dev/lib/python3.6/site-packages/matplotlib/tight\u layout.py(图、渲染器、nrows\u ncols、num2\u列表、子地块列表、ax\u bbox\u列表、pad、h\u pad、w\u pad、rect)
127继续
128
-->129 tight_bbox_raw=子批次中ax的并集([ax.get_tightbox(渲染器))
130如果ax.get_visible())
131 tight_bbox=转换的bbox(tight_bbox_原始,
/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/tight_layout.py in(.0)
128
129 tight_bbox_raw=子批次中ax的并集([ax.get_tightbox(渲染器))
-->130如果ax.get_visible())
131 tight_bbox=转换的bbox(tight_bbox_原始,
132图变形。倒置()
/get\u Tightbox中的opt/homebrew/anaconda3/envs/mda dev/lib/python3.6/site-packages/matplotlib/axes//u base.py(self、渲染器、调用轴定位器)
3952
3953如果self.title.get_可见():
->3954 bb.append(self.title.get\u window\u extent(渲染器))
3955如果self.\u left\u title.get\u visible():
3956 bb.append(self.\u left\u title.get\u window\u extent(渲染器))
/获取窗口范围(self、渲染器、dpi)中的opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/text.py
968 raise RUNTIMERROR('无法获取不带渲染器的窗口范围')
969
-->970 bbox,信息,下降=自。\获取\布局(自。\渲染器)
971 x,y=self.get_unitless_position()
972 x,y=self.get_transform().transform_point((x,y))
/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/text.py in_-get_布局(self,渲染器)
352 tmp,lp_h,lp_bl=渲染器。获取文本宽度高度下降('lp',
353自,
-->354(ismath=False)
355偏移量=(lp_h-lp_bl)*自
356
/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/backends/backend\u agg.py in get\u text\u width\u height\u description(self、s、prop、ismath)
224 fontsize=prop.get_size_in_points()
225 w,h,d=texmanager.get_text_width_height_down(
-->226秒,字体大小,渲染器=自身)
227返回w、h、d
228
/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/texmanager.py in-get\u text\u-width\u-height\u-dence(self、tex、fontsize、renderer)
602 dvifile=self.make\u dvi(tex,fontsize)
603以dviread.Dvi(dvifile,72*dpi_分数)作为Dvi:
-->604页=下一页(iter(dvi))
605#需要返回总高度(包括下降高度)。
606返回page.width,page.height+page.descent,page.descent
/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/dviread.py in uuuuu iter_uuuuu(self)
247         """
248虽然正确:
-->249 have_page=self._read()
250如果有第页:
251产量自。_输出()
/opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/dviread.py in_-read(self)
308虽然正确:
309字节=ord(self.file.read(1)[0])
-->310 self.\u dtable[字节](self,字节)
311如果字节==140:#页末
312返回真值
/包装器中的opt/homebrew/anaconda3/envs/mda-dev/lib/python3.6/site-packages/matplotlib/dviread.py(self,byte)
164如果状态不是无且self.state!=状态:
165提升值错误(“状态预处理失败”)
-->166返回方法(self,*[f(self,byte min)表示get_args中的f])
167如果最大值为无:
168表[min]=包装器
/opt/homebrew/anaconda3/envs/mda dev/lib/python3.6/site-packages/matplotlib/dviread.py in_fnt_def(self、k、c、s、d、a、l)
455@dispatch(最小值=243,最大值=246,参数=('olen1','u4','u4','u4','u1','u1'))
456定义(自、k、c、s、d、a、l):
-->457自我定义真实(k、c、s、d、a、l)
458
459 def_fnt_def_real(self、k、c、s、d、a、l):
/opt/homebrew/anaconda3/envs/mda
# Update parameters for matplotlib
params = {"text.usetex": True,
          "text.latex.unicode": True,
          "axes.unicode_minus": True,
         }
plt.rcParams.update(params)