Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib 1.4.2 with Seaborn: line markers not functioning

Note: this is fixed in 1.4.3 or later


I use the Seaborn plotting package and I just upgraded to the newest version of Matplotlib. Now, plots with dot symbols no longer render. Code that was functional before now creates blank plots, but only when Seaborn is imported. Here's some sample code:

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

print matplotlib.__version__

Matplotlib version:

1.4.2

Create a plot without 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

Import seaborn, print the version:

import seaborn as sns
print sns.__version__

Seaborn version:

0.4.0

Create a line plot with seaborn imported:

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

sin function with a solid line connecting each data point

Creating a dot plot with seaborn imported gives a blank set of axes:

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

an empty set of axes

Everything above was done in the IPython notebook, but I just tried the following in Spyder with the same result:

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()

What's going on?

like image 967
ollerend Avatar asked Oct 28 '14 20:10

ollerend


2 Answers

It would appear that this is due to a bug in Matplotlib.

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

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

You might just have to downgrade for the time being.

PS: What's up Doug.

like image 103
derricw Avatar answered Sep 23 '22 08:09

derricw


A workaround (mentioned in the GitHub links in the other answer) is to explicitly set markeredgewidth (or mew) in the call to plot:

plt.plot(x,y,'.', mew=1)
like image 28
abeboparebop Avatar answered Sep 22 '22 08:09

abeboparebop