我正在尝试创建一个matplotlib
要插入到我的LaTeX
文档中的图形,并且我需要不带圆点和帽子的粗体'i'
和'j'
符号。
我一直在使用的代码\mathbf{\hat{\textnormal{\bfseries\i}}}
在我的文档,但这里使用了amsmath
封装(或可能的amssymb
包装,对不起,我不知道我是很新的这两个LaTeX
和matplotlib
)我不能在使用它matplotlib
的标签。
因此,我很想知道如何使用LaTeX
的matplotlib
,以及如何编写一个序言安装即可使用这些符号所需要的包。我希望这是有道理的,而且我知道这可能已经存在或很简单,但是我是新手,所以请不要生气!
感谢大伙们!
编辑
因此,我已经设法通过编码使这一步走到了尽头,但是,每当我运行该代码时,我就会python kernel
崩溃。不幸的是,我不太了解自己的代码或错误代码,因此请上载以防万一。很抱歉长时间上传。再次感谢!
from mpl_toolkits.mplot3d import Axes3D
import numpy, matplotlib, matplotlib.pyplot as pyplot
matplotlib.rcParams['text.usetex'] = True
matplotlib.rcParams['text.latex.preamble'] = [
r'\usepackage{amsmath}',
r'\usepackage{amssymb}']
matplotlib.rcParams['font.family'] = 'serif'
matplotlib.rcParams['font.serif'] = 'Computer Modern'
matplotlib.verbose.level = 'debug-annoying'
Module_Colour = '#F0AE1E'
fig = pyplot.figure()
ax = fig.add_subplot(111, projection='3d')
X_arr = numpy.array([1.0,0.0,0.0])
Y_arr = numpy.array([0.0,1.0,0.0])
Z_arr = numpy.array([0.0,0.0,1.0])
O_arr = numpy.array([0.0,0.0,0.0])
pyplot.quiver(O_arr,O_arr,O_arr,X_arr,Y_arr,Z_arr,
pivot='tail', length=1.0, linewidth=2.5,
color = Module_Colour)
ax.set_xlabel('x-axis', fontsize=12.5)
ax.set_ylabel('y-axis', fontsize=12.5)
ax.set_zlabel('z-axis', fontsize=12.5)
ax.text(1.03, 0, 0, r'$\mathbf{\hat{\textnormal{\bfseries \i}}}$',
fontsize=25, color = Module_Colour)
ax.text(0, 1.03, 0, r'$\mathbf{\hat{\textnormal{\bfseries \j}}}$',
fontsize=25, color = Module_Colour)
ax.text(0, 0, 1.03, r'$\mathbf{\hat{\textnormal{\bfseries k}}}$',
fontsize=25, color = Module_Colour)
ax.set_xlim3d([0, 1.05])
ax.set_ylim3d([0, 1.05])
ax.set_zlim3d([0, 1.13])
ax.view_init(elev=17.0, azim=44.0)
pyplot.savefig('file/pathway/figure.jpeg',
bbox_inches='tight')
pyplot.show()
编辑
调试错误是:
FigureCanvasAgg.draw
RendererAgg.__init__
RendererAgg.__init__ width=800.0, height=600.0
RendererAgg.__init__ _RendererAgg done
RendererAgg.__init__ done
No LaTeX-compatible font found for the monospace font family in rcParams. Using default.
RendererAgg.points_to_pixels
No LaTeX-compatible font found for the monospace font family in rcParams. Using default.
C: && cd "C:\Users\alexd\.matplotlib\tex.cache" && latex -interaction=nonstopmode 8160df9e5349057f736eef7cf8779b4d.tex > "C:\Users\alexd\.matplotlib\tex.cache\8160df9e5349057f736eef7cf8779b4d.output"
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (MiKTeX 2.9.6100 64-bit)
entering extended mode
(8160df9e5349057f736eef7cf8779b4d.tex
LaTeX2e <2016/03/31> patch level 3
Babel <3.9r> and hyphenation patterns for 75 language(s) loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size10.clo"))
("C:\Program Files\MiKTeX 2.9\tex\latex\type1cm\type1cm.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\psnfss\helvet.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\psnfss\courier.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\base\textcomp.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\base\ts1enc.def"))
("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsmath.sty"
For additional information on amsmath, use the `?' option.
("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amstext.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsgen.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsbsy.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsopn.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amssymb.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amsfonts.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\geometry\geometry.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifvtex.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\ifxetex\ifxetex.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\geometry\geometry.cfg")
Package geometry Warning: Over-specification in `h'-direction.
`width' (5058.9pt) is ignored.
Package geometry Warning: Over-specification in `v'-direction.
`height' (5058.9pt) is ignored.
)
No file 8160df9e5349057f736eef7cf8779b4d.aux.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\ts1cmr.fd")
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
[1] (8160df9e5349057f736eef7cf8779b4d.aux) )
Output written on 8160df9e5349057f736eef7cf8779b4d.dvi (1 page, 240 bytes).
Transcript written on 8160df9e5349057f736eef7cf8779b4d.log.
Dvi: C:\Users\alexd\.matplotlib\tex.cache\8160df9e5349057f736eef7cf8779b4d.dvi
Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
find_tex_file(cmr12.tfm): [u'kpsewhich', u'cmr12.tfm']
find_tex_file result: C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmr12.tfm
opening tfm file C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmr12.tfm
lh=18, bc=0, ec=127, nw=34, nh=16, nd=10
find_tex_file(cmr12.vf): [u'kpsewhich', u'cmr12.vf']
find_tex_file result:
RendererAgg.points_to_pixels
C: && cd "C:\Users\alexd\.matplotlib\tex.cache" && latex -interaction=nonstopmode 27047192dde3a3a7381bad7b27d0fcb3.tex > "C:\Users\alexd\.matplotlib\tex.cache\27047192dde3a3a7381bad7b27d0fcb3.output"
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (MiKTeX 2.9.6100 64-bit)
entering extended mode
(27047192dde3a3a7381bad7b27d0fcb3.tex
LaTeX2e <2016/03/31> patch level 3
Babel <3.9r> and hyphenation patterns for 75 language(s) loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size10.clo"))
("C:\Program Files\MiKTeX 2.9\tex\latex\type1cm\type1cm.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\psnfss\helvet.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\psnfss\courier.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\base\textcomp.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\base\ts1enc.def"))
("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsmath.sty"
For additional information on amsmath, use the `?' option.
("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amstext.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsgen.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsbsy.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsopn.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amssymb.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amsfonts.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\geometry\geometry.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifvtex.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\ifxetex\ifxetex.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\geometry\geometry.cfg")
Package geometry Warning: Over-specification in `h'-direction.
`width' (5058.9pt) is ignored.
Package geometry Warning: Over-specification in `v'-direction.
`height' (5058.9pt) is ignored.
)
No file 27047192dde3a3a7381bad7b27d0fcb3.aux.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\ts1cmr.fd")
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
[1] (27047192dde3a3a7381bad7b27d0fcb3.aux) )
Output written on 27047192dde3a3a7381bad7b27d0fcb3.dvi (1 page, 288 bytes).
Transcript written on 27047192dde3a3a7381bad7b27d0fcb3.log.
Dvi: C:\Users\alexd\.matplotlib\tex.cache\27047192dde3a3a7381bad7b27d0fcb3.dvi
Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
find_tex_file(cmmi12.tfm): [u'kpsewhich', u'cmmi12.tfm']
find_tex_file result: C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmmi12.tfm
opening tfm file C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmmi12.tfm
lh=18, bc=0, ec=127, nw=97, nh=15, nd=9
find_tex_file(cmmi12.vf): [u'kpsewhich', u'cmmi12.vf']
find_tex_file result:
C: && cd "C:\Users\alexd\.matplotlib\tex.cache" && dvipng -bg Transparent -D 100.0 -T tight -o "da3e0f170d11553ae39831280c346c0f.png" "27047192dde3a3a7381bad7b27d0fcb3.dvi" > "C:\Users\alexd\.matplotlib\tex.cache\da3e0f170d11553ae39831280c346c0f.output"
This is dvipng 1.15 Copyright 2002-2015 Jan-Ake Larsson
[1]
然后python.exe
停止响应,很遗憾,我对技术的了解不是很深,所以很难理解为什么会这样。
当需要使用LaTeX
时matplotlib
,我将以下内容添加到python脚本中(+其他用于调试信息的命令)
import matplotlib.pyplot as plt
plt.rc('text', usetex=True)
plt.rc('text.latex', preamble=r'\usepackage{amsmath}
\usepackage{foo-name} `...')
matplotlib.verbose.level = 'debug-annoying'
在这里进行绘图的命令
对于简单的定制操作,我们或许可以通过使用layers.core.Lambda层来完成。但对于任何具有可训练权重的定制层,你应该自己来实现。 这里是一个Keras层应该具有的框架结构(1.1.3以后的版本,如果你的版本更旧请升级),要定制自己的层,你需要实现下面三个方法 build(input_shape):这是定义权重的方法,可训练的权应该在这里被加入列表`self.trainable_weigh
对于简单的定制操作,我们或许可以通过使用layers.core.Lambda层来完成。但对于任何具有可训练权重的定制层,你应该自己来实现。 这里是一个Keras2的层应该具有的框架结构(如果你的版本更旧请升级),要定制自己的层,你需要实现下面三个方法 build(input_shape):这是定义权重的方法,可训练的权应该在这里被加入列表`self.trainable_weights中。其他的属性
我想编写自己的定位器来访问元素。WebDriver的API目前提供了八个定位器,允许按id、名称属性、标记名、完整或部分链接文本、XPath、类名和css选择器检索元素。然而,这些默认定位器现在对我来说还不够,因为我必须通过一个新属性访问元素。让我举个例子,这样你就能明白我在这里真正想要的是什么。 示例:选择您的用户名: 现在,我想编写一段代码,以便使用myLocator定位器访问用户名按钮,如:
对于简单、无状态的自定义操作,你也许可以通过 layers.core.Lambda 层来实现。但是对于那些包含了可训练权重的自定义层,你应该自己实现这种层。 这是一个 Keras 2.0 中,Keras 层的骨架(如果你用的是旧的版本,请更新到新版)。你只需要实现三个方法即可: build(input_shape): 这是你定义权重的地方。这个方法必须设 self.built = True,可以通
问题内容: 我正在尝试编写自己的睡眠函数,相当于在Go中使用。 这是代码。第一次尝试: 第二次尝试: 两者都返回错误,有人可以向我解释如何编写等同于使用的睡眠函数,如果可能的话,何时使用通道? 问题答案: 返回一个频道。在指定的持续时间后,将在通道上发送一个值。 因此,只需从返回的通道接收一个值,接收就会阻塞,直到发送该值为止: 您的错误: 在第一个示例中: 已经声明,因此不能使用Short变量声
如何编写自己的Burp Suite插件 Burp Suite的强大除了自身提供了丰富的可供测试人员使用的功能外,其提供的支持第三方拓展插件的功能也极大地方便使用者编写自己的自定义插件。从上一章节我们已经了解到,Burp Suite支持的插件类型有Java、Python、Ruby三种。无论哪种语言的实现,开发者只要选择自己熟悉的语言,按照接口规范去实现想要的功能即可。下面我们就来看看如何开发一个Bu