如何用python绘制GEBCO测深数据?

如何用python绘制GEBCO测深数据?,python,numpy,matplotlib,plotly,Python,Numpy,Matplotlib,Plotly,我正在尝试绘制水深测量数据(来自)。我正在尝试使用seaborn python绘制横向、纵向和高程。数据采用netCDF格式。我使用xarray成功地正确加载了数据。 下面是代码片段 从netCDF4导入数据集 将xarray作为xr导入 ds=数据集(“gebco_2019.nc”) lats=ds.变量['lat'][:] lons=ds.variables['lon'][:] tid=ds.variables['tid'][:] 导入plotly.graph_对象作为go 图=通电图(通电

我正在尝试绘制水深测量数据(来自)。我正在尝试使用seaborn python绘制横向、纵向和高程。数据采用netCDF格式。我使用xarray成功地正确加载了数据。 下面是代码片段

从netCDF4导入数据集
将xarray作为xr导入
ds=数据集(“gebco_2019.nc”)
lats=ds.变量['lat'][:]
lons=ds.variables['lon'][:]
tid=ds.variables['tid'][:]
导入plotly.graph_对象作为go
图=通电图(通电表面(
等高线={
“x”:{“show”:True,“size”:0.04,“color”:“white”},
“z”:{“show”:真,“size”:0.05}
},
x=ds.变量['lat'],
y=ds.变量['lon'],
z=[
ds.variables['tid']
]))
图2(图3)
尝试使用python绘制3D绘图,但出现此错误。
数组的长度必须相同

我设法得到了二维图

我使用了另一种方法来检查netcdf文件是否正常(转换为)。我曾用阴谋策划

import plotly.graph_objects as go
import pandas as pd
import numpy as np
# Read data from a csv
z_data = pd.read_csv('bathy_bedford.csv')
z = z_data.values
sh_0, sh_1 = z.shape
x, y = np.linspace(44.66875, 44.74791667, sh_0), np.linspace(-63.69791667, -63.52708333, sh_1)
fig = go.Figure(data=[go.Surface(z=z, x=x, y=y)])
fig.update_traces(contours_z=dict(show=True, usecolormap=True,
                                  highlightcolor="limegreen", project_z=True))
fig.update_layout(title='Bedford Basin Elevation',xaxis_title="Latitude", 
                  yaxis_title="Longitude",autosize=False,
                  width=900, height=900, 
                  margin=dict(l=65, r=50, b=65, t=90))
fig.update_layout(scene = dict(
                    xaxis_title='Latitude',
                    yaxis_title='Longitude',
                    zaxis_title='Elevation'),
                    margin=dict(r=20, b=10, l=10, t=10))  
# fig.update_layout(color='Elevation')
fig.update_layout(coloraxis_colorbar=dict(
    title="Elevation",
    thicknessmode="pixels", thickness=50,
    lenmode="pixels", len=200,
    yanchor="top", y=1,
    ticks="outside", ticksuffix="",
    dtick=5
))
fig.show()
以下是输出图像:

您能分享您的Seaborn代码吗?这段代码似乎起作用了fine@JoshFriedlander:plotly代码工作正常,但无法获取我的图形上的任何点或轴,您知道有什么问题吗?然后我用了其他的方法来绘制