Elaborated question:
Let me clarify my question. I want to plot a list of array output as a 2D scatter plot with polarity along x axis subjectivity along y axis and modality values that ranges between -1 and 1 determines the type of marker( o,x, ^, v)
output
polarities: [ 0. 0. 0. 0.]
subjectivity: [ 0.1 0. 0. 0. ]
modalities: [ 1. -0.25 1. 1. ]
The modified code with limited marker value for 2 range.
print "polarities: ", a[:,0]
print "subjectivity: ", a[:,1]
print "modalities: ", a[:,2]
def markers(r):
markers = np.array(r, dtype=np.object)
markers[(r>=0)] = 'o'
markers[r<0] = 'x'
return markers.tolist()
def colors(s):
colors = np.array(s, dtype=np.object)
colors[(s>=0)] = 'g'
colors[s<0] = 'r'
return colors.tolist()
fig=plt.figure()
ax=fig.add_subplot(111)
ax.scatter(a[:,0], a[:,1], marker = markers(a[:,2]), color= colors(a[:,0]), s=100, picker=5)
My intent is to check the modality value and return one of the four markers. if I hardcore 'o' it returns the plot.
ax.scatter(a[:,0], a[:,1], marker = markers('o'), color= colors(a[:,0]), s=100, picker=5)
As a trial i tried to mimic the color function and pass it as a[:,2] but hit a shell output error
ValueError: Unrecognized marker style ['o', 'x', 'o', 'o']
The question is: Is my approach wrong? or how to make it recognize the marker style?
Edit1
Trying to get the m value between 0 and .5
with this code
ax.scatter (p[0<m<=.5], s[0<m<=.5], marker = "v", color= colors(a[:,0]), s=100, picker=5)
yields this error
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
How to range m value between 0 and .5 in the example given in answer 2.