python - 如何在 Matplotlib 中绘制嵌套的元组列表?
问题描述
我正在努力正确地绘制一个包含一些嵌套列表的列表。这实际上是我计算的输出结果,它们是根据我的输入数据计算出来的。所以,我想根据一对坐标绘制输出。我的样本数据如下:
temp = [(8.30014492234868, 10.076987589320124),
(6.565100209934528, 10.126390914006539),
(8.064572331389588, 9.999998485114327),
(18.801449684428746, 1.1966541400666473),
(16.39706266718748, -0.07867904744412477),
(13.489350431455016, -0.6138733861514962),
(13.668995714960388, 17.53643661173564),
(4.808988910967888, 20.76029261433188),
(1.7575932694038692, 14.404108129869353),
(3.0136007564635103, 7.318480031628899),
(2.988551059917197, 7.355468722551662),
(18.826817655400742, 0.30186049637530527),
(4.9477946187407476, 16.065642524553212),
(5.7416001839901165, 5.915851736013389),
(3.004349636718835, 7.315738092232703),
((1.481287160721499, 13.69706806608235), (4.975290244180029, 15.059417315522877)),
(9.022336802561307, 8.741822450784232),
(8.339683645685863, 9.875063384164433),
(13.625980549650077, 17.64071625638145),
(7.6474833153988016, 20.09172492469006),
(9.777767270079616, 1.7478894865558094)]
正如你所看到的,它们都是成对的,可以很容易地绘制出来,除了一个看起来像这样((1.481287160721499, 13.69706806608235), (4.975290244180029, 15.059417315522877))
:
有时我会得到很多,但我无法正确绘制它们。这是我使用的:
for x, y in temp:
plt.scatter(x, y, c='k', marker='o', s=4)
for line in temp:
xll,yll = line.xy
plt.scatter(xll, yll, color='c', lw=1, zorder=0)
但他们都没有工作。
解决方案
推荐阅读
- asp.net - 如何使用 SQL Server 将本机应用程序与 ASP.NET Web 服务连接起来?
- selenium-webdriver - Capybara点击方法传递参数导致不是key修饰符错误
- sql - 创建主列表的智能方法(避免交叉连接)
- python - 如何检查某个连续子数组的总和是否等于 N?
- wso2 - WSO2 Integrator:如何设置 FIX 发起程序故障转移?
- xcode - 控制到达 xcode 中非 void 函数的末尾
- r - 如何在 R 中绘制矩形/边界框?
- javascript - JQuery.Validate 只验证第一个字段
- c# - offzip 未检测到 Zlib 标头
- python - 求平方的另一种方法