Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matplotlib.pyplot.plot() named parameter c sometimes ignored (but color seems to always work) #4386

Closed
tlvb opened this issue Apr 27, 2015 · 2 comments

Comments

@tlvb
Copy link

tlvb commented Apr 27, 2015

Description

The documentation for matplotlib.pyplot.plot() (http://matplotlib.org/api/pyplot_api.html?highlight=plot#module-matplotlib.pyplot) states that either c=... or color=... can be used to specify line color in a plot command. For brevity's sake when autogenerating a lot of plot code I have used c without trouble, but today (120427) I have started getting inconstent results, where the color specification is sometimes—but not always—ignored if c=... is used. It does not seem to depend on wether the color is specified as a color name, hex string, or an rgb or rgba tuple.
I can't remember having this problem previously, yet when rerunning some old generated plots the error now shows up there as well (which is not surprising, as the plot generation code is still the same).

Example

import numpy as np
import matplotlib.pyplot as p
p.figure()
x =  np.array([0,1])
y0 = np.array([0,1])
y1 = np.array([1,0])
p.plot(x,y0,c='red') # sometimes plots blue
p.plot(x,y1,color='red') # always plots red
p.show()

Environment information

uname -a:
Linux blackbird 3.19.2-1-ARCH #1 SMP PREEMPT Wed Mar 18 16:36:01 CET 2015 i686 GNU/Linux
pacman -Qi python-matplotlib (excerpt):
Version : 1.4.3-2
Build Date : Sat Mar 28 15:34:07 2015
pacman -Qi python (excerpt):
Version : 3.4.3-2
Build Date : Thu Mar 26 08:52:32 2015

@WeatherGod
Copy link
Member

Which version of python? If you have just updated to py3k, there has been a
bug that has recently been fixed in master that py3k exposed. py3k
randomizes dictionary access, and it turned out that a spot in our argument
handling code was iterating over a dictionary such that sometimes 'c'
overrode 'color' and sometimes 'color' overrode 'c'.

On Mon, Apr 27, 2015 at 2:51 PM, Leo Bärring notifications@github.com
wrote:

Description

The documentation for matplotlib.pyplot.plot() (
http://matplotlib.org/api/pyplot_api.html?highlight=plot#module-matplotlib.pyplot)
states that either c=... or color=... can be used to specify line color
in a plot command. For brevity's sake when autogenerating a lot of plot
code I have used c without trouble, but today (120427) I have started
getting inconstent results, where the color specification is sometimes—but
not always—ignored if c=... is used. It does not seem to depend on wether
the color is specified as a color name, hex string, or an rgb or rgba tuple.
I can't remember having this problem previously, yet when rerunning some
old generated plots the error now shows up there as well (which is not
surprising, as the plot generation code is still the same).
Example

import numpy as np
import matplotlib.pyplot as p
p.figure()
x = np.array([0,1])
y0 = np.array([0,1])
y1 = np.array([1,0])
p.plot(x,y0,c='red') # sometimes plots blue
p.plot(x,y1,color='red') # always plots red
p.show()

Environment information

uname -a:
Linux blackbird 3.19.2-1-ARCH #1 SMP PREEMPT Wed Mar 18 16:36:01 CET 2015
i686 GNU/Linux
pacman -Qi python-matplotlib (excerpt):
Version : 1.4.3-2
Build Date : Sat Mar 28 15:34:07 2015
pacman -Qi python (excerpt):
Version : 3.4.3-2
Build Date : Thu Mar 26 08:52:32 2015


Reply to this email directly or view it on GitHub
#4386.

@tacaswell
Copy link
Member

This should have been fixed by #4198, please ping to have this re-opened if you can reproduce this with either master or the color_overhaul branch.

@tlvb Thank you for the bug report. The number of times this has been reported makes me optimistic about python 3 adoption ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants