Scatter Plot
Produce scatter plot of input data x against y.
Examples
- Simple scatter plot
::
var r : Random = Random(1)
let x = linspace<Float64>(0.0, 3.0 * PI64, num: 200)
let y = x.apply(cos) + rand(r, 200)
scatter(x, y)
Result:
.. image:: ../../../tests/imgs/scatter_plot/scatterPlot_1.png :align: center :width: 360
- Scatter plot with changing size
::
var r : Random = Random(1)
let x = linspace<Float64>(0.0, 3.0 * PI64, num: 200)
let y = x.apply(cos) + rand(r, 200)
let c = linspace<Float64>(1.0, 10.0, num: 200)
scatter(x, y, c)
Result:
.. image:: ../../../tests/imgs/scatter_plot/scatterPlot_2.png :align: center :width: 360
- Scatter plot with fixed size and changing color.
::
var r : Random = Random(1)
let x = linspace<Float64>(0.0, 3.0 * PI64, num: 200)
let y = x.apply(cos) + rand(r, 200)
let c = linspace<Float64>(1.0, 10.0, num: 200)
scatter(x, y, 6.0, c)
Result:
.. image:: ../../../tests/imgs/scatter_plot/scatterPlot_3.png :align: center :width: 360
- Scatter plot with fixed size and changing color, each marker is a filled circle.
::
var r : Random = Random(1)
let x = linspace<Float64>(0.0, 3.0 * PI64, num: 200)
let y = x.apply(cos) + rand(r, 200)
let c = linspace<Float64>(1.0, 10.0, num: 200)
let line = scatter(x, y, 6.0, c)
line.marker_face(true)
Result:
.. image:: ../../../tests/imgs/scatter_plot/scatterPlot_4.png :align: center :width: 360
- Scatter plot with large diamond-style markers.
::
var r : Random = Random(1)
let theta = linspace<Float64>(0.0, 2.0 * PI64, num: 150)
let x = theta.apply(sin) + rand(r, 150) * 0.75
let y = theta.apply(cos) + rand(r, 150) * 0.75
let line = scatter(x, y, 23.0)
line.marker(MarkerStyle.Diamond)
.. image:: ../../../tests/imgs/scatter_plot/scatterPlot_5.png :align: center :width: 360
- Scatter plot with setting of marker color and marker face color.
::
var r : Random = Random(1)
let theta = linspace<Float64>(0.0, 2.0 * PI64, num: 150)
let x = theta.apply(sin) + rand(r, 150) * 0.75
let y = theta.apply(cos) + rand(r, 150) * 0.75
let line = scatter(x, y, 6.0)
line.marker_color(0.0, 0.5, 0.5)
line.marker_face_color(0.0, 0.7, 0.7)
.. image:: ../../../tests/imgs/scatter_plot/scatterPlot_6.png :align: center :width: 360
- Scatter plot with tiling.
::
var r : Random = Random(1)
let x = linspace<Float64>(0.0, 3.0 * PI64, num: 200)
let y = x.apply(cos) + rand(r, 200)
tiledlayout(2, 1)
let ax1 = nexttile()
scatter(ax1, x, y)
let ax2 = nexttile()
let line2 = scatter(ax2, x, y)
line2.marker_face(true)
line2.marker(MarkerStyle.Diamond)
.. image:: ../../../tests/imgs/scatter_plot/scatterPlot_7.png :align: center :width: 360
- Scatter plot showing a spiral.
::
let theta = linspace<Float64>(0.0, 1.0, num: 500)
let x = theta.apply({x: Float64 => exp(x) * sin(100.0 * x)})
let y = theta.apply({x: Float64 => exp(x) * cos(100.0 * x)})
let s = scatter(x, y)
s.marker_color("b")
s.marker_face_color(0.0, 0.5, 0.5)
.. image:: ../../../tests/imgs/scatter_plot/scatterPlot_8.png :align: center :width: 360
Methods
=========================== ========================================================= Method Description =========================== ========================================================= scatter 6 methods Draw a scatter plot =========================== =========================================================
Description
.. function:: scatter(x, y)
:param x: Vector<Float64>
:param y: Vector<Float64>
:return: Line
Draw a scatter plot with :math:`y` versus :math:`x`.
.. function:: scatter(x, y, sz)
:param x: Vector<Float64>
:param y: Vector<Float64>
:param sz: Vector<Float64>
:return: Line
Draw a scatter plot with :math:`y` versus :math:`x` with size of every single point.
.. function:: scatter(x, y, sz, color)
:param x: Vector<Float64>
:param y: Vector<Float64>
:param sz: Vector<Float64>
:param color: Vector<Float64>
:return: Line
Draw a scatter plot with :math:`y` versus :math:`x` with size and color of every single point.
.. function:: scatter(x, y, sz)
:param x: Vector<Float64>
:param y: Vector<Float64>
:param sz: Float64
:return: Line
Draw a scatter plot with :math:`y` versus :math:`x` with size of all points.
.. function:: scatter(x, y, sz, color)
:param x: Vector<Float64>
:param y: Vector<Float64>
:param sz: Float64
:param color: Vector<Float64>
:return: Line
Draw a scatter plot with :math:`y` versus :math:`x` with size of all points and color of every point.
.. function:: scatter(axes, x, y)
:param axes: AxesType
:param x: Vector<Float64>
:param y: Vector<Float64>
:return: Line
Draw a scatter plot with :math:`y` versus :math:`x` in the given axes.