Stem Plot 3D
Draw 3-dimensional stem plots.
Methods
=========================== ================================ Function Description =========================== ================================ stem3() 4 functions Plot 3D stem plot. =========================== ================================
Description
.. function:: stem3(x, y, z, line_spec!)
:param x: Vector<Float64>
:param y: Vector<Float64>
:param z: Vector<Float64>
:param line_spec: String
:return: Line
Draw 3D stem plot with given data.
.. function:: stem3(z, line_spec!)
:param z: Vector<Float64>
:param line_spec: String
:return: Line
Draw 3D stem plot with :math:`z` value only.
.. function:: stem3(z, line_spec!)
:param z: Matrix<Float64>
:param line_spec: String
:return: Line
Draw 3D stem plot with :math:`z` values from a matrix.
.. function:: stem3(axes, x, y, z, line_spec!)
:param axes: AxesType
:param x: Vector<Float64>
:param y: Vector<Float64>
:param z: Vector<Float64>
:param line_spec: String
:return: Line
Draw 3D stem plot on the given axes.
Examples
- Basic 3D stem plot (providing only :math:
zvalues).
::
let x = linspace<Float64>(-PI64 / 2.0, PI64 / 2.0, num: 40)
let z = x.apply(cos)
stem3(z)
Result:
.. image:: ../../../tests/imgs/stem_plot_3d/stem_plot_3d_1.png :align: center :width: 360
- Basic 3D stem plot (providing :math:
x,y,zvalues).
::
let x = vector<Float64>(40, 1.0)
let y = linspace<Float64>(-PI64 / 2.0, PI64 / 2.0, num: 40)
let z = y.apply(cos)
stem3(x, y, z)
Result:
.. image:: ../../../tests/imgs/stem_plot_3d/stem_plot_3d_2.png :align: center :width: 360
- Stem plot for two functions (providing :math:
zvalues as a matrix).
::
let x = linspace<Float64>(-PI64 / 2.0, PI64 / 2.0, num: 40)
let Z = empty<Float64>(2, 40)
Z[0] = x.apply(sin);
Z[1] = x.apply(cos);
stem3(Z)
Result:
.. image:: ../../../tests/imgs/stem_plot_3d/stem_plot_3d_3.png :align: center :width: 360
- Stem plot with varying :math:
yand :math:z.
::
let x = linspace<Float64>(-5.0, 5.0, num: 60)
let y = x.apply(cos)
let z = x.apply({x => pow(x, 2.0)})
stem3(x, y, z)
view(-8.0, 30.0)
Result:
.. image:: ../../../tests/imgs/stem_plot_3d/stem_plot_3d_4.png :align: center :width: 360
- Stem plot showing a surface.
::
let grid_ticks = linspace<Float64>(0.0, 1.0, num: 11)
let size = 11
let x = vector<Float64>(size * size, 1.0)
let y = vector<Float64>(size * size, 1.0)
let z = vector<Float64>(size * size, 1.0)
var k = 0
for (i in 0..size) {
for (j in 0..size) {
x[k] = grid_ticks[i]
y[k] = grid_ticks[j]
z[k] = exp(grid_ticks[i] + grid_ticks[j])
k = k + 1
}
}
stem3(x, y, z)
Result:
.. image:: ../../../tests/imgs/stem_plot_3d/stem_plot_3d_5.png :align: center :width: 360
- Stem plot with filled circles.
::
let x = linspace<Float64>(-PI64, PI64, num: 40)
let z = x.apply(cos)
stem3(z, line_spec: "filled")
Result:
.. image:: ../../../tests/imgs/stem_plot_3d/stem_plot_3d_6.png :align: center :width: 360
- Stem plot with magenta crosses.
::
let x = linspace<Float64>(-PI64, PI64, num: 40)
let z = x.apply(cos)
stem3(z, line_spec: "--*m")
Result:
.. image:: ../../../tests/imgs/stem_plot_3d/stem_plot_3d_7.png :align: center :width: 360
- Stem plot with dotted lines and magenta crosses.
::
let theta = linspace<Float64>(0.0, 2.0 * PI64)
let x = theta.apply(cos)
let y = theta.apply(sin)
let z = theta
stem3(x, y, z, line_spec: ":*m")
Result:
.. image:: ../../../tests/imgs/stem_plot_3d/stem_plot_3d_8.png :align: center :width: 360
- Stem plot with custom marker, marker color, and marker face color.
::
let x = linspace<Float64>(-PI64, PI64, num: 40)
let z = x.apply(cos)
stem3(z).marker("s").marker_color("m").marker_face_color("g")
Result:
.. image:: ../../../tests/imgs/stem_plot_3d/stem_plot_3d_9.png :align: center :width: 360
- Stem plots in a tiled layout.
::
let x = linspace<Float64>(-2.0, 2.0, num: 50)
let y = x.apply({x => pow(x, 3.0)})
let z = x.apply(exp)
tiledlayout(2, 1)
let ax1 = nexttile()
stem(ax1, x, z)
let ax2 = nexttile()
stem3(ax2, x, y, z)
Result:
.. image:: ../../../tests/imgs/stem_plot_3d/stem_plot_3d_10.png :align: center :width: 360
- Stem plot with filled circles, custom color and marker face color.
::
let x = linspace<Float64>(0.0, 2.0)
let y = x.apply({x => pow(x, 3.0)})
let z = apply2(x.toMatrix(), y.toMatrix(),
{x: Float64, y: Float64 => exp(x) * cos(y)}).toVector()
stem3(x, y, z, line_spec: "filled").color("m").marker_face_color("y")
view(-10.0, 35.0)
Result:
.. image:: ../../../tests/imgs/stem_plot_3d/stem_plot_3d_11.png :align: center :width: 360