With lastest plotly.net version (4.2), when plotting a Bubble3D chart ( or Scatter3D), x/y axis cannot be renamed
xqguo opened this issue · 4 comments
Description
WIth lastest plotly.net version, bubble3d chart, x/y axis cannot be renamed
Repro steps
Please provide the steps required to reproduce the problem
- run the follow script to reproduce and see that the XAxis cannot be renamed.
#r "nuget: Plotly.NET"
open Plotly.NET
let x = [ 1;2;3;40]
let y = [ -1;2;3;80]
let z = [ 1;0;3;20]
let s = [ 10;40;30;20]
Chart.Bubble3D(x,y,z,s)
|> Chart.withXAxisStyle("testx")
|> Chart.withYAxisStyle("testy")
|> Chart.withZAxisStyle("testz")
|> Chart.showExpected behavior
All 3 axes should be renamed,
Actual behavior
Only z axis is renamed
Known workarounds
No. But in python, all the axis can be renamed, so it is likely the problem is due to the fsharp integration side rather than in plotly.js. The axes in 3d charts seem to be defined in the scene rather than in the layout directly, as the python code below suggests. However in Plotly.Net, I can find Scene types but don't know how to use it.
fig.update_layout(
scene = dict(
xaxis_title='X AXIS TITLE',
yaxis_title='Y AXIS TITLE',
zaxis_title='Z AXIS TITLE'),
width=700,
margin=dict(r=20, b=10, l=10, t=10))Related information
- win64
- .NET 8
Found a work around by using the dynamic object
#r "nuget: Plotly.NET"
open Plotly.NET
let x = [ 1;2;3;40]
let y = [ -1;2;3;80]
let z = [ 1;0;3;20]
let s = [ 10;40;30;20]
let c = Chart.Bubble3D(x,y,z,s)
let xs = LayoutObjects.LinearAxis.init( Title= Title.init "xx")
let ys = LayoutObjects.LinearAxis.init( Title= Title.init "yy" )
let zs = LayoutObjects.LinearAxis.init( Title= Title.init "zz")
let scene = LayoutObjects.Scene.init( XAxis = xs, YAxis = ys, ZAxis = zs )
let layout=Layout.init()
layout?scene <- scene
c |> Chart.withLayout layoutFor the Chart.withXAxisStyle and Chart.withYAxisStyle functions you have to set the optional Id parameter to target a scene, see for example the docs here https://plotly.net/3D-charts/3d-scatter-plots.html or #381
you don't have to do this for the z axis because zaxis is always on a scene
It worked in earlier versions because older plotly.js versions supported xaxis and yaxis that are not on the scene object for 3d plots. This is not the case anymore.
oh btw you can also always use the Chart.withScene or Chart.WithSceneStyle functions, which should look more similar to the python code you posted.