简体   繁体   English

如何用虚线连接散点图的点?

[英]How to connect the points of a scatterplot with a dashed line?

I've a scatter plot我有一个散点图

import matplotlib.pyplot as plt
import numpy as np

x = [(1,0), (0, 1), (2, 1), (3, 1)]
y = [1, 4, 8.5, 17.5]
plt.scatter([str(i) for i in x], y, linestyle='dashed', marker='s')
plt.show()

在此处输入图片说明

I tried to use the linestyle key to connect the points by a dashed line.我尝试使用linestyle键通过虚线连接点。 Unfortunately, this didn't work.不幸的是,这不起作用。

Any suggestions on how to do this?关于如何做到这一点的任何建议?

EDIT: I'm using scatter plot for the reason mentioned here编辑:由于这里提到的原因,我正在使用散点图

import matplotlib.pyplot as plt
import numpy as np

x = [(1,0), (0, 1), (2, 1), (3, 1)]
y = [1, 4, 8.5, 17.5]
plt.plot([str(i) for i in x], y, linestyle='dashed', marker='s')
plt.show()

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

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