7

注意:这在 1.4.3 或更高版本中已修复


我使用 Seaborn 绘图包,并且刚刚升级到最新版本的 Matplotlib。现在,带有点符号的绘图不再呈现。以前有效的代码现在会创建空白图,但仅在导入 Seaborn 时。这是一些示例代码:

import matplotlib.pyplot as plt
import matplotlib
import numpy as np

print matplotlib.__version__

Matplotlib 版本:

1.4.2

创建一个没有 seaborn 的情节:

x = np.linspace(0,2,101)
y = np.sin(2*np.pi*x)
plt.plot(x,y,'.')

sin 函数,每个数据点都有点

导入 seaborn,打印版本:

import seaborn as sns
print sns.__version__

海生版本:

0.4.0

使用导入的 seaborn 创建线图:

plt.plot(x,y,'-')

用实线连接每个数据点的 sin 函数

使用导入的 seaborn 创建点图会给出一组空白轴:

plt.plot(x,y,'.')

一组空的轴

上面的一切都是在 IPython 笔记本中完成的,但我只是在 Spyder 中尝试了以下操作,结果相同:

import matplotlib.pyplot as plt
import matplotlib
import numpy as np

print matplotlib.__version__

x = np.linspace(0,2,101)
y = np.sin(2*np.pi*x)
plt.figure()
plt.plot(x,y,'.')

import seaborn as sns
print sns.__version__
plt.figure()
plt.plot(x,y,'-')

plt.figure()
plt.plot(x,y,'.')

plt.show()

这是怎么回事?

4

2 回答 2

4

这似乎是由于 Matplotlib 中的一个错误。

https://github.com/matplotlib/matplotlib/issues/3711

https://github.com/mwaskom/seaborn/issues/344

您可能只需要暂时降级。

PS:怎么了道格。

于 2014-10-28T21:16:56.367 回答
1

一种解决方法(在另一个答案的 GitHub 链接中提到)是在调用中显式设置markeredgewidth(或) :mewplot

plt.plot(x,y,'.', mew=1)
于 2017-04-24T12:34:23.363 回答