带有Seaborn的matplotlib 1.4.2:行标记不起作用

时间:2014-10-28 20:57:45

标签: python numpy matplotlib seaborn

注意:这在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 function with dots at each data point

导入seaborn,打印版本:

import seaborn as sns
print sns.__version__

Seaborn版本:

0.4.0

使用seaborn导入创建线图:

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

sin function with a solid line connecting each data point

使用seaborn导入创建点图会产生一组空白轴:

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

an empty set of axes

以上所有内容都是在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()

发生了什么事?

2 个答案:

答案 0 :(得分:4)

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

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

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

您可能只需要暂时降级。

PS:道格怎么了?

答案 1 :(得分:0)

解决方法(在另一个答案的GitHub链接中提到)是在markeredgewidth的调用中明确设置mew(或plot):

plt.plot(x,y,'.', mew=1)