用线连接屏蔽点

时间:2018-10-24 21:42:34

标签: python-3.x numpy matplotlib line mask

如何将这些点与折线连接起来?我必须按顺序连接它们,以便点x = 1的y值连接点x = 2的y值,依此类推。还是可以以某种方式组合这些单独的图?

SELECT pm.receiver, pm.date_sent, pm.unread, 
    user_receiver.username AS receiver_name, 
    user_receiver.avatar AS receiver_avatar,
    user_receiver.session_id AS receiver_session_id,
    user_sender.username AS sender_name, 
    user_sender.avatar AS sender_avatar,
    user_sender.session_id AS sender_session_id
FROM pm
INNER JOIN users AS user_receiver ON pm.receiver = user_receiver.id
INNER JOIN users AS user_sender ON pm.sender = user_sender.id
WHERE sender = :id OR receiver = :id 
ORDER BY date_sent ASC 

2 个答案:

答案 0 :(得分:0)

您快到了!

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot(x[y>=0],pos, 'rs')
ax.plot(x[y<0],neg, 'bo')
ax.plot(x[y>=0],pos, 'red')
ax.plot(x[y<0],neg, 'blue')
plt.show()

这将连接点-您可以根据需要向artist分别添加任意数量的ax。每个plot都会创建一个艺术家。

enter image description here

答案 1 :(得分:0)

您已使用'rs'(红色正方形)分隔了标记。您可以在此字符串的开头添加破折号,以表明您希望将它们用一行连接起来:

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot(x[y>=0], pos, '-rs')
ax.plot(x[y<0], neg, '-bo')

如果愿意,您也可以将它们合并到同一对plot的调用中,但是可读性较低:

ax.plot(x[y>=0], pos,'-rs', x[y<0], neg, '-bo')

enter image description here