I start using Plotly.NET for plotting. Everything was OK until I start plot 3D surfaces and my axis title disappear.
There is part of the code
my_func(double[] x, string[] y, double[,] z)
//...
LinearAxis xAxis = LinearAxis();
xAxis.SetValue("title", "axis title");
Layout layout = new Layout();
layout.SetValue("xaxis", xAxis);
Trace surface = new Trace("surface");
surface.SetValue("x", x);
surface.SetValue("y", y);
surface.SetValue("z", z);
GenericChart.ofTraceObject(true, surface).WithLayout(layout: layout).Show();
And axis still the default.
I want to change AxisTitle and to know what the problem is
Please help
I try to use Plotly.NET.CSharp instead Plotly.NET
I also try this construction:
Chart.Surface<double, double, double,string>(
zData: new double[][] {new double[]{1,1}, new double[]{1,1}},
X: new double[] { 1, 2 },
Y: new double[] { 5, 10 })
.WithXAxisStyle<double, double, string>(Title: Plotly.NET.Title.init("xAxis"))
.WithYAxisStyle<double, double, string>(Title: Plotly.NET.Title.init("yAxis"))
.Show();
It doesn't help, but other functions such as WithSize, WithTraceInfo and etc. work fine
Chart.Surface<double, double, double,string>(zData: new double[][] {new double[]{1,1}, new double[]{1,1}},
X: new double[] { 1, 2 },
Y: new double[] { 5, 10 }, ShowScale: false)
.WithSize(1500,1500).WithTraceInfo(Name: "Name", ShowLegend: true, LegendGroupTitle: Plotly.NET.Title.init("TITLE") )
.Show();
You are working with the lowest API level of Plotly.NET, where you set values directly on the objects (via
SetValue). To use this layer effectively, you have to know how plotls.js (the library Plotly.NET uses) expects values. More on the different API layers can for example be read in our paperIn the case of axis objects on 3D plots, plotly.js schema differs from 2D cartesian plots by having a
sceneobject which contains the x, y, and z axis instead of directly using the layout'sxaxisandyaxisattributes (more here).So with that knowledge, you can set axis objects on 3D plots via initializing a scene object:
Edit for Plotly.NET.CSharp
in Plotly.NET.CSharp, you must set the
Idargument of theWithAxisStylemethods toScenelike this: