0

So when I use pyplot I know how to use the colours blue and red dots, 'bo' and 'ro' respectively. However I cannot find the respective colour codes for orange, yellow, green, indigo and violet (Yup I'm modelling a rainbow). I have been trying to find these colours over the internet with no luck. Can someone please give me a link to these colour codes or list them here please.

Also I don't want to produce dots but coloured lines.

2 Answers 2

1

You can use those color codes, an RGB tuple, or you can also use hex colors, which are very easy and customizable (HTML hex color charts are widely available on the web).

Here's the documentation on the color codes: http://matplotlib.org/api/colors_api.html

What 'bo' and 'ro' actually are are two concatenated strings: a one-character string representing the color plus a one-character string representing the line style, in this case, a dot. See http://matplotlib.org/users/pyplot_tutorial.html, where it explains that if you use 'b-' instead of 'bo', it means a blue line instead of a blue dot.

This means that you can use any of the color codes in the colors api link above, followed by an o. For example, a green dot should be 'go'.

If the one-character strings for colors don't suit your needs, you can follow another format:

plot(x, y, color='green', linestyle='dashed', marker='o').

You can insert color names, hex codes, or RGB tuples in the color field.

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

11 Comments

I can't find the same format colour codes. I can't even find 'ro' or 'bo' on that link.
Did you try these? They should work. I didn't find anything specifically on 'bo' or 'ro', but it might help if you share what you've already done, for more context.
hi pique. I want to get the colour codes for the remaining colours (orange, indigo and violet). I already know of 'r' and 'b' and 'y' and 'g'.
Updated to explain line styles.
okay so do I just copy these colour codes in capslock enclosed with apostrophes? I get an error when I copy that colour code :S
|
1

You can define only a few built-in colors by a single letter (in your case, 'b' and 'r' specifies the color, 'o' specifies the dot type, not the color). You can plot blue lines using 'b-', dotted blue lines using 'b.-' and so on.

The built-in colors are: b: blue g: green r: red c: cyan m: magenta y: yellow k: black w: white

Every other color can be given through their color codes.

See all color formats in the docs here.

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.