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

plot color yields inconsistent results #5199

Closed
lukasm91 opened this issue Oct 6, 2015 · 1 comment
Closed

plot color yields inconsistent results #5199

lukasm91 opened this issue Oct 6, 2015 · 1 comment

Comments

@lukasm91
Copy link

lukasm91 commented Oct 6, 2015

When using color in plt.plot(...), this may yield to inconsistent result. I would like to get this plot:

result

Using python 3.5 and matplotlib 1.4.3, and the code below, I sometimes get the image above, but sometimes I only get a blue color (rgb 0 0 255). When using color instead of c, the results are as expected as far as I tested.

Some further information: http://stackoverflow.com/questions/32964051/inconsistent-results-using-matplotlib

import matplotlib
import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()

cmap = plt.get_cmap('cubehelix')

minval = 17
maxval = 25
bounds = np.arange(minval, maxval+1)

mynorm = matplotlib.colors.Normalize(vmin = minval, vmax = maxval)
sm = matplotlib.cm.ScalarMappable(norm=mynorm, cmap=cmap)

color = sm.to_rgba(20)
ax.plot([0, 100], [0, 100], c=color, lw=2) # ERROR
#ax.plot([0, 100], [0, 100], color=color, lw=2) # OK

ax2 = fig.add_axes([0.90, 0.1, 0.03, 0.8])
cb = matplotlib.colorbar.ColorbarBase(ax2, cmap=cmap, norm=mynorm, spacing='proportional', ticks=bounds, boundaries=bounds, format='%1i')

plt.show()
@jenshnielsen
Copy link
Member

I think this is the same issue as #4162, #4157 and #5197 which has been fixed. Please ping to have this reopened if you disagree

@QuLogic QuLogic added this to the next point release (1.5.0) milestone Oct 11, 2015
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