fun matrixXYSeries()

in plot-api/src/commonMain/kotlin/org/jetbrains/letsPlot/bistro/corr/CorrUtil.kt [98:143]


    fun matrixXYSeries(
        correlations: Map<Pair<String, String>, Double>,
        variablesInOrder: List<String>,
        type: String,
        nullDiag: Boolean,
        threshold: Double,
        dropDiagNA: Boolean,
        dropOtherNA: Boolean
    ): Pair<List<String>, List<String>> {

        val xs = ArrayList<String>()
        val ys = ArrayList<String>()
        val cm = CorrMatrix(
            correlations,
            nullDiag = nullDiag,
            threshold
        )
        for ((ix, x) in variablesInOrder.withIndex()) {
            val iterY = when (type) {
                "upper" -> {
                    variablesInOrder.subList(ix, variablesInOrder.size)
                }

                "lower" -> {
                    variablesInOrder.subList(0, ix + 1)
                }

                else -> {
                    variablesInOrder
                }
            }
            for (y in iterY) {
                val v = cm.value(x, y)

                if (v == null) {
                    if (dropDiagNA && x == y) continue
                    if (dropOtherNA && x != y) continue
                }

                xs.add(x)
                ys.add(y)
            }
        }

        return Pair(xs, ys)
    }