I am plotting an 3D surface plot using X=lat, Y=long and Z=depth(Elevation) with csv. I am pretty sure the length of all the variable is same 43 but i am getting following error, What value the program is referring to ?
ValueError: shape mismatch: objects cannot be broadcast to a single shape
.
Here is my python snippet.
import matplotlib.pyplot as plt
%matplotlib inline
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_0)
#plotting
fig = plt.figure(figsize=(8,6))
ax = fig.add_subplot(1,1,1, projection='3d')
ax.plot_surface(x, y, z, rstride=4, cstride=4, alpha=0.25)
cset = ax.contour(x, y, z, zdir='z', offset=-np.pi, cmap=matplotlib.cm.coolwarm)
cset = ax.contour(x, y, z, zdir='x', offset=-np.pi, cmap=matplotlib.cm.coolwarm)
cset = ax.contour(x, y, z, zdir='y', offset=3*np.pi, cmap=matplotlib.cm.coolwarm)
ax.set_xlim3d(-np.pi, 2*np.pi);
ax.set_ylim3d(0, 3*np.pi);
ax.set_zlim3d(-np.pi, 2*np.pi);
Here is the output of the length of the variable:
len(x)
43
len(y)
43
len(z)
43