1

I might be missing something very obvious here, but I've tried numerous combinations I haven't been able to find the reason for this behavior.

I'm running Python v2.7.6 and matplotlib v1.4.3.

I have a simple plot:

import matplotlib.pyplot as plt
import numpy as np
x, y = np.random.random(50), np.random.random(50)
plt.plot(x, y, c='red', ls='-', lw=1., label='a', zorder=2)
plt.show()

Notice that the color is supposed to be red as per c='red'. What I get instead is:

enter image description here

If I use the full name of the argument color='red', the line is red as it should. If I remove any of the arguments after c='red', e.g.:

plt.plot(x, y, c='red', ls='-', lw=1., label='a')
plt.plot(x, y, c='red', ls='-', lw=1., zorder=2)
plt.plot(x, y, c='red', ls='-', label='a', zorder=2)
plt.plot(x, y, c='red', lw=1., label='a', zorder=2)

the plotted line is also red.

Am I doing something very obviously wrong here or did I stumble into a weird issue?


Add:

Using:

plt.plot(x, y, c='r', ls='-', lw=1., label='a', zorder=2)

as proposed (i.e.: c='r' instead of c='red') has no effect on my system, I still get the blue line.

3
  • You're not suppose to write c='red', it's c='r' Commented Oct 5, 2015 at 19:44
  • Writing c='r' changes nothing in my system, I still get a blue line. Commented Oct 5, 2015 at 19:46
  • 1
    @FreddieV4 it should work just fine with c='red'. Notice that it works when one of the arguments is taken away. Also, it's in the docs. "Finally, legal html names for colors, like ‘red’, ‘burlywood’ and ‘chartreuse’ are supported." Commented Oct 5, 2015 at 19:49

2 Answers 2

1

The following information work with Python 3.x and matplotlib 1.4.3

c='r' found in docs

import matplotlib.pyplot as plt
import numpy as np
x, y = np.random.random(50), np.random.random(50)
plt.plot(x, y, c='r', ls='-', lw=1., label='a', zorder=2)
plt.show()

enter image description here

As it seems color='red' and color='r' seem to work along with c='r'. c='red' does not change the line color.

Sign up to request clarification or add additional context in comments.

9 Comments

Nope, this has no effect on my system. what versions of Python and matplotlib are you running?
Also in the docs. "Finally, legal html names for colors, like ‘red’, ‘burlywood’ and ‘chartreuse’ are supported."
Python 3.4. c='red' doesn't work for me, c=r does. Running same version of mpl as you.
try color='red' or color='r'
@Leb as I said in the question, I already know that using color='red' works and as I've commented above, using c='r' has no effect on my system. Perhaps its something that was fixed in v3 of Python.
|
0

This is a known issue and the fix will be released with v1.5.0.

See issue at Github for more details: https://github.com/matplotlib/matplotlib/issues/5197

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.