我列出了一个元组列表(每个元组代表一个2D点),然后我想使用pyplot对其进行绘制。所以我的问题是,我无法通过切片列表来仅获得x个协调员。这是我正在使用的代码
points = [(1,2), (3,4), (5,6)]
plt.plot(points[:][0], points[:][1], 'o')
如果我想打印
in: print(points[:][0])
out: (1, 2)
您是否知道如何获取第一个元组元素的列表?
答案 0 :(得分:0)
@ForceBru的解决方案
select t.*
from (select t.*,
sum(orders) over (order by orders desc range between unbounded preceding and current row) as running_orders,
sum(orders) over (partition by orders) as all_with_this_order,
sum(orders) over () as total_orders
from t
) t
where (running_orders - all_with_this_order) < 0.75 * total_orders;
或更简单的方法(x,y现在是元组)
points = [(1,2), (3,4), (5,6)]
x = [p[0] for p in points]
y = [p[1] for p in points]
答案 1 :(得分:0)
您需要做的就是理解列表,如下所示:
points = [(1,2), (3,4), (5,6)]
x_coordinats = [x[0] for x in points]
y_coordinats = [y[0] for y in points]