Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
Check it out now!Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
I'm trying to post a 3D scatter plot on the Service but I am getting the error. If I remove the ax formatting I get it, but it's not what I expect.
Does anyone know any alternative?
Below is the error message, a screenshot of how it beautifully looks on Desktop and what I could get on the Service.
To replicate it I am providing the M code to generate the data and the Python viz (ax formatting lines commented with #).
Script Runtime Error
fig.add_axes(ax)
[S-ecccd5b8-55de-460e-b32a-be84188e4e5c]NotImplementedError: It is not currently possible to manually set the aspect on 3D axes
Please try again later or contact support. If you contact support, please provide these details.
On Desktop
On Service, removing the ax formatting
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZTBasMwDIZfJXiXFEqQbSm1r2kvg1IGG3Rb6KHQwQppC2XvT52uW5eAZ/8Ho0T580myZbWtWuy3h6J8XE3UVK33u6/Pn5enbns8fuyK9UtRLpvn3vUa1ltY72HNT93pXGm1mbZKKDi8rmbByIxcML2HKro9PRD5pnZ3sZPrNzHeBsMykrvGEVFMLoTJMfpdLFm5QHJNoB7kG5BvQL5N8odtMN76//vAgtkwWC2DfAH5kuTXXElfqDf8e7o3xlXva27i+u/TBfQg34J8m+QPu0GPL+64HYZ4BtNhsFwB+QLy/zZIVjqYXhP6AxrBoBFMOkJ8vmVcGIsmZNGSGY3AaARJR4jP9IwhZFJbGp/oOXKMzjH65gI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t, Column7 = _t]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Z", type number}, {"Y", type number}, {"X", type number}, {"Planned WT (LBS)", type number}, {"Width (IN)", type number}, {"Diam (IN)", type number}})
in
#"Changed Type"
# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:
# dataset = pandas.DataFrame(Diam (IN), X, Y, Z, Width (IN), Railcar)
# dataset = dataset.drop_duplicates()
# Paste or type your script code here:
df = dataset
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.path import Path
import numpy as np
def plot_cylinder(x, y, z, r, h, cylinder_color):
if y == 0:
y = r
elif y > 0:
y = y + r + 5
def data_for_cylinder_along_z(center_x,center_y,radius,height_z):
z = np.linspace(0, height_z, 50)
theta = np.linspace(0, 2*np.pi, 50)
theta_grid, z_grid=np.meshgrid(theta, z + h)
x_grid = radius*np.cos(theta_grid) + center_x
y_grid = radius*np.sin(theta_grid) + center_y
return x_grid,y_grid,z_grid
Xc,Yc,Zc = data_for_cylinder_along_z(x+r, y, r, z)
ax.plot_surface(Xc,Yc,Zc,
alpha=0.95,
color= cylinder_color,
#cmap='Set1',
rstride=3,
cstride=3
)
fig = plt.figure(figsize=(7,4))
ax = Axes3D(fig)
fig.add_axes(ax)
#ax.set_xlim3d(0, 600)
#ax.set_ylim3d(0, 108)
#ax.set_zlim3d(0, 154)
#ax.set_zticks(np.arange(0, 154, step=10))
#ax.zaxis.set_tick_params(labelsize=5)
#ax.set_yticks(np.arange(0, 108, step=25))
#ax.yaxis.set_tick_params(labelsize=5)
#ax.set_xticks(np.arange(0, 600, step=25))
#ax.xaxis.set_tick_params(labelsize=5)
#ax.set_aspect('equal', adjustable='box')
for i, row in df.iterrows():
plot_cylinder(
int(row['X']),
int(row['Z']),
int(row['Width (IN)']),
int(row['Diam (IN)']) / 2,
int(row['Y']),
row['Color.1']
)
ax.view_init(30, -40)
plt.show()
I can see it in the workspace. It just doesn't render when I use the ax formatting properties and methods 😞
Setting it to "auto" i get this in the desktop
and this in the service
It looks a little better, but not quite what I wanted/expected.
Am I right in affirming there is no way yet of keeping the real proportions among the axes?
Don't know about that but there is certainly some version mismatch and/or deprecation involved.
Are you running the Personal Gateway on your PC?
BTW, your sample data gives me this:
Hi @lbendlin ,
I just published to My Workspace to test. No gateway setup yet.
I would like to have the output like this, in a rectangular aspect ratio, not a square.
Please try uncommenting the lines in the Python viz code to see if you get the same error I got on the Service.
My understanding is that you need a personal gateway set up, and running, to see these visuals in the workspace.