Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 以不同颜色设置散点图的1点_Python_Matplotlib - Fatal编程技术网

Python 以不同颜色设置散点图的1点

Python 以不同颜色设置散点图的1点,python,matplotlib,Python,Matplotlib,我有一个像这样的散点图 f,ax=plt.subplots() ax.scatter(keyByte0To255,highestCorrVector) ax.set_title('Key: ' + hex(getIndex)) ax.set_ylabel('Correlation Value') ax.set_xlabel('Hypothesis 0-255') 如何设置红色0.5的最高值?在黑暗中拍摄时,可以重新绘制点: f,ax=plt.subplots() ax.scatter(key

我有一个像这样的散点图

f,ax=plt.subplots()
ax.scatter(keyByte0To255,highestCorrVector)
ax.set_title('Key: ' + hex(getIndex))
ax.set_ylabel('Correlation Value')
ax.set_xlabel('Hypothesis 0-255')


如何设置红色0.5的最高值?

在黑暗中拍摄时,可以重新绘制点:

f,ax=plt.subplots()
ax.scatter(keyByte0To255,highestCorrVector)

# find the point
idx = np.argmax(highestCorrVector)
ax.scatter(keyByte0To255[idx], highestCorrVector[idx], c='red')

ax.set_title('Key: ' + hex(getIndex))
ax.set_ylabel('Correlation Value')
ax.set_xlabel('Hypothesis 0-255')

在黑暗中拍摄,您可以重新绘制点:

f,ax=plt.subplots()
ax.scatter(keyByte0To255,highestCorrVector)

# find the point
idx = np.argmax(highestCorrVector)
ax.scatter(keyByte0To255[idx], highestCorrVector[idx], c='red')

ax.set_title('Key: ' + hex(getIndex))
ax.set_ylabel('Correlation Value')
ax.set_xlabel('Hypothesis 0-255')
或使用cmap:

import matplotlib.pyplot as plt

x_values = [20, 19, 16, 12, 19, 18, 22, 14]
y_values = [1, 0.91, 0.77, 0.67, 0.85, 0.78, 1.05, 0.63]

maxx = max(y_values)

marker_colors = [100 if el == maxx else 0 for el in y_values ]
plt.scatter(x_values, y_values, c=marker_colors, cmap='bwr')

plt.colorbar()

plt.show()
或使用cmap:

import matplotlib.pyplot as plt

x_values = [20, 19, 16, 12, 19, 18, 22, 14]
y_values = [1, 0.91, 0.77, 0.67, 0.85, 0.78, 1.05, 0.63]

maxx = max(y_values)

marker_colors = [100 if el == maxx else 0 for el in y_values ]
plt.scatter(x_values, y_values, c=marker_colors, cmap='bwr')

plt.colorbar()

plt.show()

谢谢您的帮助!谢谢你的帮助!