简体   繁体   English

散点图中的黑点

[英]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! 这不会导致黑点!

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: 编辑:也许可以使事情更清楚一些:您可以用不同的方式在pyplot中指定颜色:

  • use built-in colors accessible via strings (eg color="blue" or c="b" ) 使用可通过字符串访问的内置颜色(例如color="blue"c="b"
  • use greyshades via floats in the range of 0-1 (eg color=0.75 ) 通过0-1范围内的浮点数使用灰度阴影(例如color=0.75
  • use hex-strings (eg color='#eeefff' ) 使用十六进制字符串(例如color='#eeefff'
  • use rgb-tuples, each in the range of 0-1 (eg color=(0.5, 0.5, 0.5) ) 使用rgb-tuple,每个在0-1的范围内(例如color=(0.5, 0.5, 0.5)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM