plotting a colored symbol with plot command

Relatively new user here. I need to place a series of white colored dots on a map. I’ve been able to place black dots using:

plt.plot(x,y,color=‘k’,marker=’.’,markersize=3.0)

The color option in this command does not plot the chosen color, only black. The command:

plt.plot(x,y,‘wo’)

places white dots with black around the edges. I see that the
‘w’ is for white and ‘o’ is for the symbol. I’d like to use the former command since that gives me control over marker size and a dot without a black edge.

Lastly, it’s not clear to me if I should be using plt.plot or just plot. Both work, and I don’t know the difference.

Hey Michael!

Welcome :slight_smile:

Relatively new user here. I need to place a series of white colored dots on a map. I've been able to place black dots using:

plt.plot(x,y,color='k',marker='.',markersize=3.0)

You can change the colour with:

plt.pyplot(x, y, color='g', marker='.', markersize=3.0)

That will plot a green dot.

The color option in this command does not plot the chosen color, only black. The command:

plt.plot(x,y,'wo')

You can change the colour of the edge with the 'markeredgecolour'
option, or 'mec' for short:

plt.plot(x, y, 'wo', mec='w')

Kablam! Big white Os with no black edge.
You can also control the size of the marker there, too:

plt.plot(x, y, 'wo', mec='w', markersize=10.0)

places white dots with black around the edges.� I see that the 'w' is for white and 'o' is for the symbol. I'd like to use the former command since that gives me control over marker size and a dot without a black edge.

Lastly, it's not clear to me if I should be using plt.plot or just plot. Both work, and I don't know the difference.

If you're using pylab, it doesn't matter:

In [5]: print plot
<function plot at 0x10cddbd70>

In [6]: print plt.plot
<function plot at 0x10cddbd70>

They are *literally* the same function in memory.

Hope this helps, Michael.
Good luck!

···

On Fri, Aug 24, 2012 at 01:00:13PM -0700, Michael Rawlins wrote:

--
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

Hey Michael!

Welcome :slight_smile:

>
> Relatively new user here. I need to place a series of white colored dots on a map. I've been able to place black dots using:
>
> plt.plot(x,y,color='k',marker='.',markersize=3.0)
>

You can change the colour with:

plt.pyplot(x, y, color='g', marker='.', markersize=3.0)

That will plot a green dot.

>
> The color option in this command does not plot the chosen color, only black. The command:
>
> plt.plot(x,y,'wo')
>

You can change the colour of the edge with the 'markeredgecolour'

Sorry! That should me 'markeredgecolor'. All commands are American
spelling.

If I had a penny for every time I got a syntax error for using British
spelling, I'd have about 3 pence.

···

On Fri, Aug 24, 2012 at 09:20:47PM +0100, Damon McDougall wrote:

On Fri, Aug 24, 2012 at 01:00:13PM -0700, Michael Rawlins wrote:

option, or 'mec' for short:

plt.plot(x, y, 'wo', mec='w')

Kablam! Big white Os with no black edge.
You can also control the size of the marker there, too:

plt.plot(x, y, 'wo', mec='w', markersize=10.0)

>
> places white dots with black around the edges.� I see that the 'w' is for white and 'o' is for the symbol. I'd like to use the former command since that gives me control over marker size and a dot without a black edge.
>
> Lastly, it's not clear to me if I should be using plt.plot or just plot. Both work, and I don't know the difference.

If you're using pylab, it doesn't matter:

In [5]: print plot
<function plot at 0x10cddbd70>

In [6]: print plt.plot
<function plot at 0x10cddbd70>

They are *literally* the same function in memory.

Hope this helps, Michael.
Good luck!

--
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

--
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

···

From: Damon McDougall <damon.mcdougall@…287…>
To: Michael Rawlins <rawlins02@…9…>
Cc: "matplotlib-users@lists.sourceforge.net" matplotlib-users@lists.sourceforge.net
Sent: Friday, August 24, 2012 4:22 PM
Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command

On Fri, Aug 24, 2012 at 09:20:47PM +0100, Damon McDougall wrote:

Hey Michael!

Welcome :slight_smile:

On Fri, Aug 24, 2012 at 01:00:13PM -0700, Michael Rawlins wrote:

Relatively new user here. I need to place a series of white colored dots on a map. I’ve been able to place black dots using:

plt.plot(x,y,color=‘k’,marker=’.’,markersize=3.0)

You can change the colour with:

plt.pyplot(x, y, color=‘g’, marker=’.’, markersize=3.0)

That will plot a green dot.

Damon,

plt.pyplot gives an error:

AttributeError: ‘module’ object has no attribute ‘pyplot’

If I use plt.plot(x, y, color=‘g’, marker=’.’, markersize=3.0)

the dots are black. But I’ve found success with:

plt.plot(x,y,‘wo’,markeredgecolor=‘white’,markersize=3.0)

so all is well. Thanks for your
help.

The color option in this command does not plot the chosen color, only black. The command:

plt.plot(x,y,‘wo’)

You can change the colour of the edge with the ‘markeredgecolour’


Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

________________________________
From: Damon McDougall <damon.mcdougall@...287...>
To: Michael Rawlins <rawlins02@...9...>
Cc: "matplotlib-users@lists.sourceforge.net" <matplotlib-users@lists.sourceforge.net>
Sent: Friday, August 24, 2012 4:22 PM
Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command

plt.pyplot gives an error:

AttributeError: 'module' object has no attribute 'pyplot'

Sorry, that's my mistake. It should be plt.plot

If I use plt.plot(x, y, color='g', marker='.', markersize=3.0)

the dots are black.

That should not happen... Have you tried some of the other colours? 'r',
'b', 'm', 'y', 'c'? Are they all black? What are you saving the file as? What
is the output of:

plt.get_backend()

···

On Fri, Aug 24, 2012 at 02:39:12PM -0700, Michael Rawlins wrote:

On Fri, Aug 24, 2012 at 09:20:47PM +0100, Damon McDougall wrote:

But I've found success with:

plt.plot(x,y,'wo',markeredgecolor='white',markersize=3.0)

so all is well. Thanks for your help.

--
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

···

From: Damon McDougall <damon.mcdougall@…287…>
To: Michael Rawlins <rawlins02@…9…>
Cc: "matplotlib-users@lists.sourceforge.net" <matplotlib-users@…1738…net>
Sent: Saturday, August 25, 2012 4:21 AM
Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command

On Fri, Aug 24, 2012 at 02:39:12PM -0700, Michael Rawlins wrote:


From: Damon McDougall <damon.mcdougall@…287…>
To: Michael Rawlins <rawlins02@…9…>
Cc: “matplotlib-users@…1739…ge.net” <matplotlib-users@…431…ists.sourceforge.net>
Sent: Friday, August 24, 2012 4:22 PM
Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command

On Fri, Aug 24, 2012 at 09:20:47PM +0100, Damon McDougall wrote:

If I use plt.plot(x, y, color=‘g’, marker=’.’, markersize=3.0)

the dots are black.

That should not happen… Have you tried some of the other colours? ‘r’,
‘b’, ‘m’, ‘y’, ‘c’? Are they all black? What are you saving the file as? What
is the output of:

plt.get_backend()

Yes I’ve tried several. All produce black dots. The output of that command is ‘agg’. I use:

plt.savefig(‘map.eps’)

to produce eps images.


Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

Bizarre. I am still seeing green dots.

Could you provide a very minimal example for which you see black dots?
It'd be nice to understand what's going on.

Also, what's the output of

import matplotlib
print matplotlib.__version__

Thanks.

···

On Sat, Aug 25, 2012 at 07:59:52AM -0700, Michael Rawlins wrote:

________________________________
From: Damon McDougall <damon.mcdougall@...287...>
To: Michael Rawlins <rawlins02@...9...>
Cc: "matplotlib-users@lists.sourceforge.net" <matplotlib-users@lists.sourceforge.net>
Sent: Saturday, August 25, 2012 4:21 AM
Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command

On Fri, Aug 24, 2012 at 02:39:12PM -0700, Michael Rawlins wrote:
>
>� From: Damon McDougall <damon.mcdougall@...287...>
> To: Michael Rawlins <rawlins02@...9...>
> Cc: "matplotlib-users@lists.sourceforge.net" <matplotlib-users@lists.sourceforge.net>
> Sent: Friday, August 24, 2012 4:22 PM
> Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command
>�
> On Fri, Aug 24, 2012 at 09:20:47PM +0100, Damon McDougall wrote:

>
> If I use plt.plot(x, y, color='g', marker='.', markersize=3.0)
>
> the dots are black.

That should not happen... Have you tried some of the other colours? 'r',
'b', 'm', 'y', 'c'? Are they all black? What are you saving the file as? What
is the output of:

plt.get_backend()

Yes I've tried several. All produce black dots. The output of that command is 'agg'.� I use:

plt.savefig('map.eps')

to produce eps images.

--
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom


From: Damon McDougall <damon.mcdougall@…287…>
To: Michael Rawlins <rawlins02@…9…>
Cc: "matplotlib-users@lists.sourceforge.net" matplotlib-users@lists.sourceforge.net
Sent: Saturday, August 25, 2012 4:21 AM
Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command


From: Damon McDougall <damon.mcdougall@…287…>

To: Michael Rawlins <rawlins02@…9…>
Cc: “matplotlib-users@…642…ts.sourceforge.net” matplotlib-users@lists.sourceforge.net

Sent: Friday, August 24, 2012 4:22 PM
Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command

If I use plt.plot(x, y, color=‘g’, marker=’.’, markersize=3.0)

the dots are black.

That should not happen… Have you tried some of the other colours? ‘r’,

‘b’, ‘m’, ‘y’, ‘c’? Are they all black? What are you saving the file as? What
is the output of:

plt.get_backend()

Yes I’ve tried several. All produce black dots. The output of that command is ‘agg’. I use:

plt.savefig(‘map.eps’)

to produce eps images.

The default ‘markeredgecolor’ (or ‘mec’) is black, and with small dots, you will see more edge color than face color. To test this, create the same plot but with an exaggerated marker size, e.g. markersize=30. If that is the problem, you can fix it by also setting the edge color to green, e.g. mec=‘g’.

Warren

[Sending to the list this time–forgot to “reply to all” the first time.]

···

On Sat, Aug 25, 2012 at 9:59 AM, Michael Rawlins <rawlins02@…9…> wrote:

On Fri, Aug 24, 2012 at 02:39:12PM -0700, Michael Rawlins wrote:

On Fri, Aug 24, 2012 at 09:20:47PM +0100, > Damon McDougall wrote:


Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick

Coventry
West Midlands
CV4 7AL
United Kingdom


Live Security Virtual Conference

Exclusive live event will cover all the ways today’s security and

threat landscape has changed and how IT managers can respond. Discussions

will include endpoint security, mobile security and the latest in malware

threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

···

From: Warren Weckesser <warren.weckesser@…1036…>
To: “matplotlib-users@…1220…sts.sourceforge.net” matplotlib-users@lists.sourceforge.net
Sent: Saturday, August 25, 2012 11:13 AM
Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command

On Sat, Aug 25, 2012 at 9:59 AM, Michael Rawlins <rawlins02@…9…> wrote:


From: Damon McDougall <damon.mcdougall@…287…>
To: Michael Rawlins <rawlins02@…9…>
Cc: “matplotlib-users@…1867…s.sourceforge.net” matplotlib-users@lists.sourceforge.net
Sent: Saturday, August 25, 2012 4:21 AM
Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command

On Fri, Aug 24, 2012 at 02:39:12PM -0700, Michael Rawlins wrote:


From: Damon McDougall <damon.mcdougall@…287…>

To: Michael Rawlins <rawlins02@…878…9…>
Cc: "matplotlib-users@lists.sourceforge.net" matplotlib-users@lists.sourceforge.net

Sent: Friday, August 24, 2012 4:22 PM
Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command

On Fri, Aug 24, 2012 at 09:20:47PM +0100, > Damon McDougall wrote:

If I use plt.plot(x, y, color=‘g’, marker=’.’, markersize=3.0)

the dots are black.

That should not happen… Have you tried some of the other colours? ‘r’,

‘b’, ‘m’, ‘y’, ‘c’? Are they all black? What are you saving the file as? What
is the output of:

plt.get_backend()

Yes I’ve tried several. All produce black dots. The output of that command is ‘agg’. I use:

plt.savefig(‘map.eps’)

to produce eps images.

The default ‘markeredgecolor’ (or ‘mec’) is black, and with small dots, you will see more edge color than face color. To test this, create the same plot but with an exaggerated marker size, e.g. markersize=30. If that is the problem, you can fix it by also setting the edge color to green, e.g. mec=‘g’.

Warren

[Sending to the list this time–forgot to “reply to all” the first time.]

Success. I’ve made the markers larger. The correct color is being plotted. As Warren suggested, without specifying markeredgecolor I see mostly black border with the smaller marker size. Thanks to all for the help.


Live Security Virtual Conference

Exclusive live event will cover all the ways today’s security and

threat landscape has changed and how IT managers can respond. Discussions

will include endpoint security, mobile security and the latest in malware

threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Live Security Virtual Conference
Exclusive live event will cover all the ways today’s security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


Matplotlib-users mailing list
Matplotlib-users@…1738…net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users