matplotlib动画:更新轴tick ticks

发布于 2025-02-03 03:10:38 字数 708 浏览 1 评论 0原文

我正在创建一个图像的动画,其轴值随时间变化。

all_data是一个矩阵,其中包含一个斧头时间框架中的一个矩阵,有3个Quatities是经度的纬度和像素值 因此,

lon = All_data[0,0] #-> lon is a 2D nxm matrix
lat = All_data[0,1] #-> lat is a 2D nxm matrix
I = All_data[0,2]    #-> I   is a 2D nxm matrix
im = axis.pcolormesh(lon,lat,I)
def animate(i):
    im.set_array(All_data[i,2])
    #code to add here to update axis too
    return im

ani = FuncAnimation.....etc

问题在于,此代码不会更新我的X和Y(经度和态度)轴。 有什么方法可以使用PCOLOR或PCOLORMESH甚至IMShow更新图像的轴值? 结果显示在图像中显示,因为您看到轴的值没有更改 ”在此处输入图像描述”

I'm creating an animation of an image with axis values varying over time.

All_data is a matrix that contains in one axe time frames inside there are 3 quatities which are longitude latitude and pixel values
so

lon = All_data[0,0] #-> lon is a 2D nxm matrix
lat = All_data[0,1] #-> lat is a 2D nxm matrix
I = All_data[0,2]    #-> I   is a 2D nxm matrix
im = axis.pcolormesh(lon,lat,I)
def animate(i):
    im.set_array(All_data[i,2])
    #code to add here to update axis too
    return im

ani = FuncAnimation.....etc

The problem is that this code will not update my X and Y (longitude and attitude) axis.
is there any way to update the axis values with images using pcolor or pcolormesh or even imshow?
The results are shown in the image as you see the values of the axis are not changingenter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

大海や 2025-02-10 03:10:38

我尚未使用您的代码进行测试(问题可以使用 mwe ),但是您可能能够做类似的事情:

# Form relative steps in coordinates between frames for each frame
dlon = np.r_[0, All_data[1:, 0] - All_data[:-1, 0]]
dlat = np.r_[0, All_data[1:, 1] - All_data[:-1, 1]]

def animate(i):
    im.set_array(All_data[i, 2])
    new_coords = im.properties()['coordinates']  # N x M x 2 array
    new_coords[..., 0] += dlon[i]
    new_coords[..., 1] += dlat[i]
    im._coordinates = new_coords  # is there a public interface?

    return im

I haven't tested this with your code (the question could use an MWE), but you might be able to do something like:

# Form relative steps in coordinates between frames for each frame
dlon = np.r_[0, All_data[1:, 0] - All_data[:-1, 0]]
dlat = np.r_[0, All_data[1:, 1] - All_data[:-1, 1]]

def animate(i):
    im.set_array(All_data[i, 2])
    new_coords = im.properties()['coordinates']  # N x M x 2 array
    new_coords[..., 0] += dlon[i]
    new_coords[..., 1] += dlat[i]
    im._coordinates = new_coords  # is there a public interface?

    return im

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文