簡體   English   中英

在python中獲取特定圖的網格點

[英]Get grid points of a specific plot in python

我已經使用matplotlib繪制了地圖。 我想要地圖內所有網格點的坐標,而忽略地圖外所有網格點。 有什么可以直接使用的方法嗎? Intertools提供了所有網格點,但我只希望地圖上的點。

import matplotlib.pylab as pt
import itertools
pt.set_xticks(np.arange(65,100,.75))
pt.set_yticks(np.arange(0,100,.75))
gridpoints = list( itertools.product(xticks, yticks) )
print gridpoints

我不確定您要做什么,但我敢猜測。 如果您要獲取繪圖上的所有網格線相交點,則可以嘗試如下操作:

def getGridPoints(ax):
    xticks = ax.get_xticks()
    yticks = ax.get_yticks()
    xmin, xmax = ax.get_xbound()
    ymin, ymax = ax.get_ybound()

    return list( itertools.product( [x for x in xticks if x>xmin and x<xmax],
                                    [y for y in yticks if y>ymin and y<ymax]))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM