2

This is likely an elementary question, but I can't figure out how to plot black points in a scatter plot!

import matplotlib.pyplot as plt
x = range(255)
y = range(255)
color = range(255)
plt.scatter(x, y, c=color)

This does not result in black dots!

1 Answer 1

7

Not sure if this is what you want, but why not simply specify the color to be black?

import matplotlib.pyplot as plt
x = range(255)
y = range(255)
# color = range(255)  not needed?
plt.scatter(x, y, c='black')

Edit: To make things a little more clear maybe: You can specify colors in pyplot in different ways:

  • use built-in colors accessible via strings (e.g. color="blue" or c="b")
  • use greyshades via floats in the range of 0-1 (e.g. color=0.75)
  • use hex-strings (e.g. color='#eeefff')
  • use rgb-tuples, each in the range of 0-1 (e.g. color=(0.5, 0.5, 0.5))

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.