Hi,
Windows XP
Python 2.5.2
matplotlib 0.98.5.2
I try to use numpoints for a legend my plot, but without luck. I always
end up having three points in the legend despite setting numpoints=1 (see
below towards the end of the code).
Things work nicely though in a much simpler script.
Help is greatly appreciated.
Cheers
Oliver
[CODE START]
# Import necessary modules
import numpy as np
import matplotlib.pyplot as plt
# Import data for correlation plot
assC = np.loadtxt('Apples_flowerFlavour_assC_corrPlot.txt')
all = np.loadtxt('Apples_flowerFlavour_allAssessors_corrPlot.txt')
x_assC = assC[:,1].copy()
y_assC = assC[:,0].copy()
x_all = all[:,1].copy()
y_all = all[:,0].copy()
# 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_assC[0]], [y_assC[0]], s=50, c='r', marker='s', label='Apple
Golden')
ax.scatter([x_assC[1]], [y_assC[1]], s=50, c='r', marker='v',
label='Granny Smith')
ax.scatter([x_assC[2]], [y_assC[2]], s=50, c='r', marker='d', label='Green
Star')
ax.scatter([x_assC[3]], [y_assC[3]], s=50, c='r', marker='^',
label='Kanzi')
ax.scatter([x_assC[4]], [y_assC[4]], s=50, c='r', marker='>', label='Pink
Lady')
ax.scatter([x_assC[5]], [y_assC[5]], s=50, c='r', marker='<', label='Royal
Gala')
ax.scatter([x_assC[6]], [y_assC[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, numpoints=1)
ltext = plt.gca().get_legend().get_texts()
plt.setp(ltext[0], fontsize = 10, color = 'k')
ax.set_xlabel('panel average')
ax.set_ylabel('assessor C')
plt.show()
[CODE END]
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users