小编Ben*_*o94的帖子

Seaborn乳胶标签

我正在尝试使用带有LaTeX标签的seaborn.kdeplot进行绘图。我尝试了以下内容:

import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(font_scale=1.5, rc={'text.usetex' : True})

x = np.linspace(-50,50,100)
y = np.sin(x)**2/x

fig = plt.figure(1)
sns.set_style('white')
sns.kdeplot(np.array(y), label='hey')
fig.gca().set(xlabel=r'$e(t_0)$ [s]', ylabel='PDF')
fig.savefig("seaborntest.png", close = True, verbose = True)
Run Code Online (Sandbox Code Playgroud)

运行此错误信息:

Traceback (most recent call last):
  File "./sns_problem.py", line 17, in <module>
    fig.savefig("seaborntest.png", close = True, verbose = True)
  File "/usr/lib64/python2.7/site-packages/matplotlib/figure.py", line 1363, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/matplotlib/backend_bases.py", line 2093, in print_figure
    **kwargs)
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 491, …
Run Code Online (Sandbox Code Playgroud)

python plot labels seaborn

5
推荐指数
1
解决办法
3472
查看次数

标签 统计

labels ×1

plot ×1

python ×1

seaborn ×1