Hi,
I am not sure whether this has been
reported before or maybe even got fixed already. When I make scatter plot
and plot a point with marker = ‘o’ it appears as a circle in the plot as
it should. It won’t, however, appear in the legend.
Windows XP
Python(x,y) 2.6.0
matplotlib 0.99.1 (I think
Example:
ax.scatter([x_assF[6]], [y_assF[6]],
s=35, c=‘r’, marker=‘o’, label=‘Ecological’)
doesn’t show in the legend. When I change
the same line of code to
ax.scatter([x_assF[6]], [y_assF[6]],
s=35, c=‘r’, marker=‘8’, label=‘Ecological’)
that is, the marker is now set to marker=‘8’,
then it will appear as a circle in the legend. Is this a bug or am I messing
something up here? Finde complete code and data sets below:
[CODE START]
-- coding: utf-8 --
“”"
correlationPlot_fig15.2.py
“”"
Import necessary modules
import numpy as np
import matplotlib.pyplot as plt
Import data for correlation plot
assF = np.loadtxt(‘Apples_flowerFlavour_assF_corrPlot.txt’)
all = np.loadtxt(‘Apples_flowerFlavour_allAssessors_corrPlot.txt’)
x_assF = assF[:,1].copy()
y_assF = assF[:,0].copy()
x_all = all[:,1].copy()
y_all = all[:,0].copy()
Plot correlation plot values
fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(x_all, y_all, s=10, c=‘w’,
marker=‘o’, edgecolor=‘grey’, label=’_’)
NOTE: label=’_’ excludes the lable
from legend
ax.scatter([x_assF[0]], [y_assF[0]],
s=50, c=‘r’, marker=‘s’, label=‘Alpe Golden’)
ax.scatter([x_assF[1]], [y_assF[1]],
s=50, c=‘r’, marker=‘v’, label=‘Granny Smith’)
ax.scatter([x_assF[2]], [y_assF[2]],
s=50, c=‘r’, marker=‘d’, label=‘Green Star’)
ax.scatter([x_assF[3]], [y_assF[3]],
s=50, c=‘r’, marker=’^’, label=‘Kanzi’)
ax.scatter([x_assF[4]], [y_assF[4]],
s=50, c=‘r’, marker=’>’, label=‘Pink Lady’)
ax.scatter([x_assF[5]], [y_assF[5]],
s=50, c=‘r’, marker=’<’, label=‘Royal Gala’)
ax.scatter([x_assF[6]], [y_assF[6]],
s=35, c=‘r’, marker=‘o’, label=‘Ecological’)
ax.plot([0,10], [0,10], ‘b–’)
ax.set_xlim(0,10)
ax.set_ylim(0,10)
Fix legend settings
plt.legend(loc=‘lower right’, shadow=True,
scatterpoints=1)
ltext = plt.gca().get_legend().get_texts()
plt.setp(ltext[0], fontsize = 10, color
= ‘k’)
ax.set_xlabel(‘Score - panel average’)
ax.set_ylabel(‘Score - assessor F’)
plt.show()
[CODE END]
Vennlig hilsen / Yours sincerely**
Oliver Tomic**
Research scientist, Dr. scient
Osloveien 1
1430 Ås
Norway
Tel: +47 6497 0252
Mob: +47 9574 6167
oliver.tomic@…2673…
/ www.nofima.no
Apples_flowerFlavour_AssF_corrPlot.txt (61 Bytes)
Apples_flowerFlavour_allAssessors_corrPlot.txt (563 Bytes)