problems with numpoints in legend

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]

···

When posting an example, it helps if we can run it:-) In this case,
we would need your data files

assC = np.loadtxt('Apples_flowerFlavour_assC_corrPlot.txt')
all = np.loadtxt('Apples_flowerFlavour_allAssessors_corrPlot.txt')

JDH

···

On Mon, Jul 6, 2009 at 6:06 AM, Oliver Tomic<oliver.tomic@...2673...> wrote:

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.

The number of points in scatter plot has other keyword argument
(scatterpoints). This is true for svn version, but I'm not quite sure
if it is also true for 0.98.5.2.
Anyhow, the documentation still needs to be updated.

Regards,

-JJ

···

On Sat, Jul 11, 2009 at 9:46 AM, John Hunter<jdh2358@...287...> wrote:

On Mon, Jul 6, 2009 at 6:06 AM, Oliver Tomic<oliver.tomic@...2673...> wrote:

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.

When posting an example, it helps if we can run it:-) In this case,
we would need your data files

assC = np.loadtxt('Apples_flowerFlavour_assC_corrPlot.txt')
all = np.loadtxt('Apples_flowerFlavour_allAssessors_corrPlot.txt')

JDH

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Jae-Joon and John,

thank you for your help. Just a few
minutes before I read your emails I found a thread in the archives (from
a few months back) where Jae-Joon anwered exactly the same question.

http://www.nabble.com/legend-bug–td22466216.html#a22466216

Sorry, that I overlooked that last time
searched in the archives. ‘Scatterpoints=1’ did what I needed.

Thanks again for your thelp.

Cheers

OIiver

`Jae-Joon Lee <lee.j.joon@…287…> wrote on
11.07.2009 16:42:29:

From:`

`>

Jae-Joon Lee <lee.j.joon@…287…>`

`>

To:`

`>

John Hunter <jdh2358@…287…>`

`>

Cc:`

`>

Oliver Tomic <oliver.tomic@…2673…>, matplotlib-users@lists.sourceforge.net`

`>

Date:`

`>

11.07.2009 16:47`

`>

Subject:`

`>

Re: [Matplotlib-users] problems with numpoints in legend`

`>

The number of points in scatter plot has other keyword argument

(scatterpoints). This is true for svn version, but I’m not quite sure

if it is also true for 0.98.5.2.

Anyhow, the documentation still needs to be updated.

Regards,

-JJ

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.

When posting an example, it helps if we can run it:-) In
this case,

we would need your data files

assC = np.loadtxt(‘Apples_flowerFlavour_assC_corrPlot.txt’)

all = np.loadtxt(‘Apples_flowerFlavour_allAssessors_corrPlot.txt’)

JDH


Enter the BlackBerry Developer Challenge

This is your chance to win up to $100,000 in prizes! For a limited
time,

vendors submitting new applications to BlackBerry App World™
will have

the opportunity to enter the BlackBerry Developer Challenge.
See full prize

details at: [http://p.sf.net/sfu/Challenge`](http://p.sf.net/sfu/Challenge)`


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

[https://lists.sourceforge.net/lists/listinfo/matplotlib-users`](matplotlib-users List Signup and Options)`


Enter the BlackBerry Developer Challenge

This is your chance to win up to $100,000 in prizes! For a limited
time,

vendors submitting new applications to BlackBerry App World™ will
have

the opportunity to enter the BlackBerry Developer Challenge. See full
prize

details at: [http://p.sf.net/sfu/Challenge`](http://p.sf.net/sfu/Challenge)`


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

[https://lists.sourceforge.net/lists/listinfo/matplotlib-users`](matplotlib-users List Signup and Options)`

`

···

On Sat, Jul 11, 2009 at 9:46 AM, John Hunter<jdh2358@…287…> wrote:

On Mon, Jul 6, 2009 at 6:06 AM, Oliver Tomic<oliver.tomic@…2673…> wrote: