[英]Using seaborn, how can I add a data point of a different color to my scatterplot or change to color of last data point?
要在自定义x
和y
坐标处添加点 ,请添加matplotlib.pyplot.scatter
和坐标:
plt.scatter(x=3, y=0.5, color='r')
为了给最后一点 .iloc
,请在数据上使用.iloc
定位符:
plt.scatter(iris.petal_length.iloc[-1], iris.petal_width.iloc[-1], color='r')
请注意 , iloc
定位器来自pandas
,而plt.scatter
来自matplotlib.pyplot
。 这两个都是seaborn的强制性依赖项,因此,如果您使用的是seaborn,则一定要将它们安装在计算机上。
例如:
import seaborn as sns
import matplotlib.pyplot as plt
iris = sns.load_dataset("iris")
grid = sns.JointGrid(iris.petal_length, iris.petal_width, space=0, size=6, ratio=50)
grid.plot_joint(plt.scatter, color="g")
# add your point
plt.scatter(x=3, y=0.5, color='r')
# or
# plt.scatter(iris.petal_length.iloc[-1], iris.petal_width.iloc[-1], color='r')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.