bf4785d2创建于 2022年9月19日历史提交

Parallel Coordinates

Given a matrix of values, plot the connections between each pair of consecutive rows in the matrix. If there are :math:n rows in the matrix, then there are :math:n-1 parts to the plot.

Examples

  1. Basic parallel plot, setting custom labels on the middle axis.

::

let x = zeros<Float64>(3, 100)
var r: Random = Random(0)
x[0] = concat(rand(r, 50, 78.0, 100.0), rand(r, 50, 65.0, 91.0))
x[1] = concat(vector<Float64>(50, 1.0), vector<Float64>(50, 0.0))
x[2] = concat(rand(r, 50, 122.0, 140.0), rand(r, 50, 105.0, 131.0))

let p: ParallelLines = parallelplot(x)

xticks(vector([1.0, 2.0, 3.0]))
xticklabels(["f_1", "f_2", "f_3"])

p.axis()[1].tick_values(vector([0.0, 1.0]))
p.axis()[1].ticklabels(["false", "true"])

Result:

.. image:: ../../../tests/imgs/parallel_plot/parallel_plot1.png :align: center :width: 360

  1. Parallel plot with four axes, setting custom labels on the second and fourth axes.

::

let x = zeros<Float64>(4, 100)
var r: Random = Random(0)
x[0] = concat(rand(r, 50, 78.0, 200.0), rand(r, 50, 65.0, 91.0))
x[1] = concat(vector<Float64>(50, 1.0), vector<Float64>(50, 0.0))
x[2] = concat(rand(r, 50, 122.0, 140.0), rand(r, 50, 105.0, 131.0))
x[3] = concat([vector<Float64>(25, 3.0), vector<Float64>(50, 1.0),
               vector<Float64>(25, 2.0)])

let p: ParallelLines = parallelplot(x, x[3])

xticks(vector([1.0, 2.0, 3.0, 4.0]))
xticklabels(["f_1", "f_2", "f_3", "f_4"])

p.axis()[1].tick_values(vector([0.0, 1.0]))
p.axis()[1].ticklabels(["false", "true"])

p.axis()[3].tick_values(vector([1.0, 2.0, 3.0]))
p.axis()[3].ticklabels(["low", "medium", "high"])

Result:

.. image:: ../../../tests/imgs/parallel_plot/parallel_plot2.png :align: center :width: 360

  1. Setting color of each line according to its value.

::

let x = empty<Float64>(4, 100)
var r: Random = Random(0)
x[0] = randn(r, 100, 50.0, 200.0)
let p = rand(r, 100, -30.0, 30.0)
let p2 = rand(r, 100, -30.0, 30.0)
x[1] = x[0] + p
for (i in 0..100) {
    if (x[0, i] > 50.0) {
        x[2, i] = 1.0
    } else {
        x[2, i] = -1.0
    }
    x[3, i] = cos(p2[i])
}
let color = x[2]
parallelplot(x, color)

Result:

.. image:: ../../../tests/imgs/parallel_plot/parallel_plot3.png :align: center :width: 360

Methods

============================== =============================== Method Description ============================== =============================== parallelplot 2 methods Draw a parallelplot ============================== ===============================

Description

.. function:: parallelplot(x)

:param x: Matrix<Float64>

Draw a parallelplot with the given matrix.

.. function:: parallelplot(x, color)

:param x: Matrix<Float64>
:param color: Vector<Float64>

Draw a parallelplot with the given matrix and setting of colors.