日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python画多边形_python – 使用matplotlib更有效地绘制多边形

發(fā)布時間:2025/3/15 python 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python画多边形_python – 使用matplotlib更有效地绘制多边形 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

您可以考慮創(chuàng)建多邊形的集合而不是單個多邊形。

舉個例子:

import numpy as np

import matplotlib.pyplot as plt

from matplotlib.collections import PolyCollection

import matplotlib as mpl

# Generate data. In this case, we'll make a bunch of center-points and generate

# verticies by subtracting random offsets from those center-points

numpoly, numverts = 100, 4

centers = 100 * (np.random.random((numpoly,2)) - 0.5)

offsets = 10 * (np.random.random((numverts,numpoly,2)) - 0.5)

verts = centers + offsets

verts = np.swapaxes(verts, 0, 1)

# In your case, "verts" might be something like:

# verts = zip(zip(lon1, lat1), zip(lon2, lat2), ...)

# If "data" in your case is a numpy array, there are cleaner ways to reorder

# things to suit.

# Color scalar...

# If you have rgb values in your "colorval" array, you could just pass them

# in as "facecolors=colorval" when you create the PolyCollection

z = np.random.random(numpoly) * 500

fig, ax = plt.subplots()

# Make the collection and add it to the plot.

coll = PolyCollection(verts, array=z, cmap=mpl.cm.jet, edgecolors='none')

ax.add_collection(coll)

ax.autoscale_view()

# Add a colorbar for the PolyCollection

fig.colorbar(coll, ax=ax)

plt.show()

HTH,

總結(jié)

以上是生活随笔為你收集整理的python画多边形_python – 使用matplotlib更有效地绘制多边形的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。