0

I am trying to plot multiple lines on a single graph using matplotlib, primarily by following this tutorial: https://matplotlib.org/gallery/showcase/bachelors_degrees_by_gender.html#sphx-glr-gallery-showcase-bachelors-degrees-by-gender-py

However, I notice that the color sequence is hardcoded.

Is there anyway to call them by name instead ?

Thanks,

1
  • What do you mean by "call them by name"? What do you want to call and which name is it you are talking about? It's always hard to help without a proper problem description. Commented Jul 5, 2018 at 18:11

1 Answer 1

1

If you mean "call them by name" as writing "red", or "r" instead of "#ff0000"(hex code for red), there are some colors which are recognized by matplotlib, namely

b: blue
g: green
r: red
c: cyan
m: magenta
y: yellow
k: black
w: white

You can read more about it here. You could also create a custom dictionary that you can map some other colors to their respective RGB/hex values.

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

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.