2

How can I plot on a colorbar?

If for example I create a colorbar that range from 0,1 and I want to mark a with a red line the values 0.3 and 0.8 , how can I do it?

Thanks,

1 Answer 1

3

Actually I managed to find the answer

from matplotlib.pyplot import imshow, colorbar

data = [[0.0,0.2],[0.5,1.0]]
imshow(data)

cb = colorbar()
cb.ax.plot([0,1],[cb.norm(0.3),cb.norm(0.3)],'r')
cb.ax.plot([0,1],[cb.norm(0.8),cb.norm(0.8)],'r')
Sign up to request clarification or add additional context in comments.

1 Comment

I added a few lines to make your answer runnable.

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.