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()
谢谢您的帮助!谢谢你的帮助!