简体   繁体   中英

How to plot a scatter of coordinates

I have the next lists:

pickup_nodes = [(42,29), (42,5),(69,134),(53,17)]

dropoff_nodes =[(54,176),(40,41),(0,37),(96,114)]

I want to draw a scatter of each list and differentiate between them with colors.........any help? each pair in each list represents (x,y)

Here's a quick and dirty solution using matplotlib :

import matplotlib.pyplot as plt
plt.scatter([i[0] for i in pickup_nodes], [i[1] for i in pickup_nodes], c='red')
plt.scatter([i[0] for i in dropoff_nodes], [i[1] for i in dropoff_nodes], c='blue')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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