0

my code is like;

m = np.where(data['Education']== 'Undergraduate','*','o')
colors = np.where(data["Education"]== "Undergraduate",'r','b')
data.plot.scatter(x="Weight",y="Height",c=colors, marker=m)
plt.show()

it works for colours but doesn't work for marker. Please help!!

genco
  • 35
  • 6
  • 1
    which graphing library you are using? – Amit Jan 08 '20 at 10:36
  • pandas , matplotlib.pyplot – genco Jan 08 '20 at 10:38
  • marker takes a single value and not a list or array. You will have to break your chart in two steps. First line for Undergraduates and the next line for non-Undergraduates. Nice discussion is here (https://stackoverflow.com/questions/43528300/python-matplotlib-scatter-different-markers-in-one-scatter) – Amit Jan 08 '20 at 10:42
  • colors = np.where(data["Education"]== "Undergraduate",'r','b') data.plot.scatter(x="Weight",y="Height",c=colors) plt.scatter(data['Education'] == 'Graduate, marker = 'o' ) plt.scatter(data['Education'] == 'Undergraduate', marker='s') plt.show() – genco Jan 08 '20 at 11:20
  • you mean like that? – genco Jan 08 '20 at 11:21
  • Yes something like that .. Did it work? I think you have to pass the Weight and Height attributes as well. – Amit Jan 08 '20 at 11:28

1 Answers1

0

Something on the following lines .. is my suggestion.

plt.scatter(x=data.Weight[data['Education'] == 'Graduate'],y=data.Height[data['Education'] == 'Graduate'],c='r', marker='*')
plt.scatter(x=data.Weight[data['Education'] == 'Undergraduate'],y=data.Height[data['Education'] == 'Undergraduate'],c='b', marker='o')
plt.show()
Amit
  • 2,018
  • 1
  • 8
  • 12