Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Black points in scatter plot

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!

like image 615
makansij Avatar asked Apr 20 '26 12:04

makansij


1 Answers

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))
like image 198
Dux Avatar answered Apr 22 '26 04:04

Dux