[use case] Add a surface plot to this plot.
Add a surface plot to this plot.
The values of z. This is an iterable of iterables of
any type T
, provided an instance of the typeclass Writable[T]
exists.
The values of zs
are oriented such that zs(0)(1)
corresponds to
the value of z at xs(1)
and
.ys(0)
Copy of this plot with the surface added.
[use case] Add a surface plot to this plot.
Add a surface plot to this plot.
The values of z. This is an iterable of iterables of
any type T
, provided an instance of the typeclass Writable[T]
exists.
The values of zs
are oriented such that zs(0)(1)
corresponds to
the value of z at xs(1)
and
.ys(0)
Options controlling the style in which the surface is drawn.
Copy of this plot with the surface added.
[use case] Add a surface plot to this plot with default x and y.
Add a surface plot to this plot with default x and y.
This adds a surface plot where x and y values are assumed to range from
0 to zs(0).size
and 0 to zs.size
respectively.
The values of z. This is an iterable of iterables of
any type T
, provided an instance of the typeclass Writable[T]
exists.
The values of zs
are oriented such that zs(0)(1)
corresponds to
the value of z at x = 1 and y = 0.
Copy of this plot with the surface added.
[use case] Add a surface plot to this plot with default x and y.
Add a surface plot to this plot with default x and y.
This adds a surface plot where x and y values are assumed to range from
0 to zs(0).size
and 0 to zs.size
respectively.
The values of z. This is an iterable of iterables of
any type T
, provided an instance of the typeclass Writable[T]
exists.
The values of zs
are oriented such that zs(0)(1)
corresponds to
the value of z at x = 1 and y = 0.
Options controlling the style in which the surface is drawn.
Copy of this plot with the surface added.
Set options for the x-axis
Set options for the x-axis
The new option values.
Copy of this plot with the new axis options set.
val zs = Vector.tabulate(3, 4) { (i, j) => util.Random.nextDouble } val p = ThreeDPlot() .withSurface(zs) .xAxisOptions(AxisOptions().title("x-axis").noZeroLine) .yAxisOptions(AxisOptions().title("y-axis").titleColor(255, 0, 0)) .zAxisOptions(AxisOptions().title("z-axis").noGrid)
Set options for the y-axis
Set options for the y-axis
The new option values.
Copy of this plot with the new axis options set.
val zs = Vector.tabulate(3, 4) { (i, j) => util.Random.nextDouble } val p = ThreeDPlot() .withSurface(zs) .xAxisOptions(AxisOptions().title("x-axis").noZeroLine) .yAxisOptions(AxisOptions().title("y-axis").titleColor(255, 0, 0)) .zAxisOptions(AxisOptions().title("z-axis").noGrid)
Set options for the z-axis
Set options for the z-axis
The new option values.
Copy of this plot with the new axis options set.
val zs = Vector.tabulate(3, 4) { (i, j) => util.Random.nextDouble } val p = ThreeDPlot() .withSurface(zs) .xAxisOptions(AxisOptions().title("x-axis").noZeroLine) .yAxisOptions(AxisOptions().title("y-axis").titleColor(255, 0, 0)) .zAxisOptions(AxisOptions().title("z-axis").noGrid)
Plot with 3D axes
Example usage
This class represents plots with 3D Cartesian axes. This can be used to draw 3D surface plots.
ThreeDPlot
instances can be sent directly to Plotly:They can also be embedded in Figure instances for more complex plot layouts:
Surface plots
Add a surface plot with the
withSurface
method:The z-values are assumed to be nested iterables, oriented such that
zs(0)(1)
is the value of z atxs(1)
andys(0)
.You can also pass in options to control how the surface is represented:
See the documentation for SurfaceOptions for a list of available options.
.withSurface
also supports passing azs
iterable withoutxs
andys
. This is equivalent to havingxs = (0 to zs(0).size)
andys = (0 to zs.size)
.Multiple surfaces
ThreeDPlot
instances support multiple surfaces:The immutable builder pattern
When you call the
.withSurface
method on aThreeDPlot
object, it returns a new plot with the series added.ThreeDPlot
instances are immutable. Thus, the following does not work as expected:You should chain calls to
withSurface
instead:val plot = ThreeDPlot() .withSurface(zs1) .withSurface(zs2)
All methods in this class work in the same way: they return a new instance of
ThreeDPlot
. This pattern is called the immutable builder pattern: it is a variant of the common builder pattern adapted for immutable objects.