0

我运行一个从 html 代码行中检索数据的脚本。然后我将这些数据绘制在地图上。现在,我使用以下脚本来绘制我在地图上检索到的所有数字,其中 c.high0 是我从 html 脚本中提取的数字。

for c in cities :
    c.retrieveTemps()
    long, lat = c.long, c.lat
    x, y = map(float(long), float(lat))
    plt.text(x, y, c.high0, fontsize=7, fontweight='bold')

这可以正常工作,但是,我只想绘制 >= 34 的数字。有没有办法做到这一点,也许在 plt.text 行中?我难住了。谢谢!

4

1 回答 1

1

关于什么:

for c in cities :
    c.retrieveTemps()
    long, lat = c.long, c.lat
    x, y = map(float(long), float(lat))
    if c.high0 >= 34:
        plt.text(x, y, c.high0, fontsize=7, fontweight='bold')

如果您确实需要在 plt 行内执行此操作:

plt.text(x, y, c.high0 if c.high0 >= 34 else '', fontsize=7, fontweight='bold')
于 2013-09-12T04:00:47.493 回答