Stackplot ‘isfinite’ Error

I was trying to do a stackplot basically like this,

../../_images/stackplot_demo_01_00.png

Figure from: http://matplotlib.org/examples/pylab_examples/stackplot_demo.html

The code was the following,

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

f = “move_user_prop_dist.csv”
df1 = pd.read_csv(f).set_index(“dist_bin_center”)
df1 = df1.drop(df1.columns[0],axis=1).transpose()

x = np.array(df1.index)
y1 = df1[25]
y2 = df1[75]
y3 = df1[125]

fig,ax = plt.subplots()
y = np.vstack((y1,y2,y3))
ax.stackplot(x,y)
plt.show()

 

However, Error comes out:

TypeError: ufunc ‘isfinite’ not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ”safe”

Found no solution online so far. Suggestions welcomed.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s