Stem Plot
Plot stem plot, which can be thought of as scatter plot with line between each point and the axis.
Methods
=========================== ================================ Function Description =========================== ================================ stem() 4 functions Plot a stem plot. =========================== ================================
Description
.. function:: stem(x, y, line_spec!)
:param x: Vector<Float64>
:param y: Vector<Float64>
:param line_spec: String
:return: Line
Draw stem plot with :math:`y` against :math:`x`.
.. function:: stem(y, line_spec!)
:param y: Matrix<Float64>
:param line_spec: String
:return: Array<Line>
Draw a series of stem plots, one for each row in :math:`y`.
.. function:: stem(x, y, line_spec!)
:param x: Vector<Float64>
:param y: Matrix<Float64>
:param line_spec: String
:return: Array<Line>
Draw a series of stem plots, one for each row in :math:`y` against :math:`x`.
.. function:: stem(axes, x, y, line_spec!)
:param axes: AxesType
:param x: Vector<Float64>
:param y: Vector<Float64>
:param line_spec: String
:return: Line
Draw stem plot on a given axes.
Examples
- Stem plot of two functions (:math:
yvalues only).
::
let x = linspace<Float64>(0.0, 2.0 * PI64, num: 50)
let Y = empty<Float64>(2, 50);
Y[0] = x.apply(cos);
Y[1] = x.apply({x => 0.5 * sin(x)})
stem(Y, line_spec: "-o")
Result:
.. image:: ../../../tests/imgs/stem_plot/stem_plot_1.png :align: center :width: 360
- Stem plot of a single function (:math:
xagainst :math:y).
::
let x = linspace(0.0, 2.0 * PI64, num: 50)
let y = x.apply(cos)
stem(x, y)
Result:
.. image:: ../../../tests/imgs/stem_plot/stem_plot_2.png :align: center :width: 360
- Stem plot of two functions (:math:
xagainst :math:y).
::
let x = linspace<Float64>(0.0, 2.0 * PI64, num: 50)
let Y = empty<Float64>(2, 50);
Y[0] = x.apply(cos);
Y[1] = x.apply({x => 0.5 * sin(x)})
stem(x, Y)
Result:
.. image:: ../../../tests/imgs/stem_plot/stem_plot_3.png :align: center :width: 360
- Two stem plots superimposed onto each other.
::
let x1 = linspace(0.0, 2.0 * PI64, num: 50)
let y1 = x1.apply(cos)
let x2 = linspace(PI64, 3.0 * PI64, num: 50)
let y2 = x2.apply(sin) * 0.5
stem(x1, y1);
hold(true);
stem(x2, y2);
Result:
.. image:: ../../../tests/imgs/stem_plot/stem_plot_4.png :align: center :width: 360
- Stem plot with custom style (filled circle).
::
let x = linspace(0.0, 10.0, num: 20)
let y = x.apply({x: Float64 => exp(0.25 * x)})
stem(x, y, line_spec: "filled")
Result:
.. image:: ../../../tests/imgs/stem_plot/stem_plot_5.png :align: center :width: 360
- Stem plot with custom style (red diamond).
::
let x = linspace(0.0, 2.0 * PI64, num: 50)
let y = x.apply({x: Float64 => exp(x) * sin(x)})
stem(x, y, line_spec: ":dr");
Result:
.. image:: ../../../tests/imgs/stem_plot/stem_plot_6.png :align: center :width: 360
- Stem plot with dashed lines, red solid circle and green borders.
::
let x = linspace(0.0, 2.0 * PI64, num: 25)
let y = x.apply({x: Float64 => cos(2.0 * x)})
stem(x, y).line_style("-.").marker_face_color("red")
.marker_color("green")
Result:
.. image:: ../../../tests/imgs/stem_plot/stem_plot_7.png :align: center :width: 360
- Two stem plots in a tiled layout.
::
let x = linspace(0.0, 25.0, num: 26)
let y1 = x.apply({x: Float64 => exp(0.1 * x)})
let y2 = x.apply({x: Float64 => -exp(0.05 * x)})
tiledlayout(2, 1)
let ax1 = nexttile()
stem(ax1, x, y1)
let ax2 = nexttile()
stem(ax2, x, y2)
Result:
.. image:: ../../../tests/imgs/stem_plot/stem_plot_8.png :align: center :width: 360
- Stem plot with the :math:
x-axis hidden.
::
let x = linspace(0.0, 2.0 * PI64, num: 50)
let y = x.apply({x: Float64 => exp(0.3 * x) * sin(3.0 * x)})
stem(x, y)
gca().x_axis().zero_axis(false)
Result:
.. image:: ../../../tests/imgs/stem_plot/stem_plot_9.png :align: center :width: 360