0

I have pandas dataframe named red_all that looks like this:

      a*         b*  
s1    32.649998 9.950000
s2    45.359997 18.160000
s3    50.539997 23.759998
s4    54.269997 33.019997
s5    44.219997 29.029999
s6    32.349998 20.830000
s7    17.320000 12.360000

I would like to plot b* (y-axis) vs a* (x-axis) with each of the point having a different marker and different label. So far I have tried this:

s = ['o','v','<','>','p','s','8']
dis_red = ['6.3%r/94.7%w','25%r/75%w','50%r/50%w','red','98.5%r/1.5%b','94.1r/5.9%b','80%r/20%b']

plt.figure(1)
plt.plot(red_all['a*'], red_all['b*'], 'r', marker=s, label=dis_red)
plt.grid()
plt.axis([-60, 60, -60, 85])
plt.xlabel('Chromaticity a*',fontsize=16, fontweight = 'bold')
plt.ylabel('Chromaticity b*', fontsize=16, fontweight = 'bold')
plt.legend(loc='best')

When I try to run it I get:

ValueError: Unrecognized marker style ['o', 'v', '<', '>', 'p', 's', '8']

How can I fix this? Thank you

2 Answers 2

1

This is another way of doing what I wanted:

figure1_red = zip(red_all['a*'].values,red_all['b*'].values,s,dis_red)
plt.figure(1)
for i in range(0,len(red_all['a*'])):
    plt.plot(figure1_red[i][0],figure1_red[i][1],'r',marker=figure1_red[i][2],label=figure1_red[i][3])
plt.grid()
plt.xlabel('Chromaticity a*',fontsize=16, fontweight = 'bold')
plt.ylabel('Chromaticity b*', fontsize=16, fontweight = 'bold')
plt.legend(loc='best')

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

Perhaps you are looking for a scatter plot:

vx = [0, 1, 2, 3, 4, 5, 6]
vy = [0, 1, 2, 3, 4, 5, 6]

s = ['o','v','<','>','p','s','8']
l = ['label%s' % i for i in range(7)]

for x, y, marker, label in zip(vx, vy, s, l):
    plt.scatter(x, y, c='r', marker=marker)
    plt.annotate(label, (x, y))

enter image description here

3 Comments

@diegus: you can use annotate. I updated my answer.
@diegus: you can read the annotate documentation. You could play with the xytext parameter in order to move the annotation a bit. ;-)
It is too bad that pandas cannot handle lists of markers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.