All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.danielTucano.matplotlib.pyplot.subplots.kt Maven / Gradle / Ivy

Go to download

Matplotlib for kotlin: A simple graph plot library for kotlin with powerful python matplotlib

The newest version!
package io.github.danielTucano.matplotlib.pyplot

import io.github.danielTucano.extensions.toPythonBooleanOrNone
import io.github.danielTucano.matplotlib.Axes
import io.github.danielTucano.matplotlib.Axes.Companion.axesNumber
import io.github.danielTucano.matplotlib.Figure
import io.github.danielTucano.matplotlib.Figure.Companion.figureNumber
import io.github.danielTucano.matplotlib.toKwargPythonDictOrNone
import io.github.danielTucano.python.PythonScriptBuilder

fun subplots(
    nrows: Int = 1,
    ncols: Int = 1,
    sharex: Boolean = false,
    sharey: Boolean = false,
    squeeze: Boolean = true,
    subplot_kw: Map? = null,
    gridspec_kw: Map? = null
): Pair {
    val figAxes = Pair(
        object : Figure {
            override val variableName: String = "figure_$figureNumber"
        },
        object : Axes {
            override val variableName: String = "axes_$axesNumber"
        }
    )
    PythonScriptBuilder.addCommand(
        "${figAxes.first.variableName}, ${figAxes.second.variableName} = plt.subplots(" +
                "nrows=$nrows," +
                "ncols=$ncols," +
                "sharex=${sharex.toPythonBooleanOrNone()}," +
                "sharey=${sharey.toPythonBooleanOrNone()}," +
                "squeeze=${squeeze.toPythonBooleanOrNone()}," +
                "subplot_kw=${subplot_kw.toKwargPythonDictOrNone()}," +
                "gridspec_kw=${gridspec_kw.toKwargPythonDictOrNone()}" +
                ")"
    )
    return figAxes
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy