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

io.github.danielTucano.matplotlib.pyplot.figure.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.extensions.toPythonStringOrNone
import io.github.danielTucano.extensions.toPythonTupleString
import io.github.danielTucano.matplotlib.Figure
import io.github.danielTucano.matplotlib.toPythonTupleStringOrNone
import io.github.danielTucano.python.PythonScriptBuilder
import java.awt.Color

fun figure(
    num: Int? = null,
    figsize: Pair? = null,
    dpi: Float? = null,
    facecolor: Color? = null,
    edgecolor: Color? = null,
    frameon: Boolean? = null,
    clear: Boolean = false,
): Figure {
    return object : Figure {
        override val variableName: String = "figure_${Figure.figureNumber}"

        init {
            PythonScriptBuilder.addCommand(
                "$variableName = plt.figure(" +
                        "num=${num.toPythonStringOrNone()}," +
                        "figsize=${figsize.toPythonTupleString()}," +
                        "dpi=${dpi.toPythonStringOrNone()}," +
                        "facecolor=${facecolor.toPythonTupleStringOrNone()}," +
                        "edgecolor=${edgecolor.toPythonTupleStringOrNone()}," +
                        "frameon=${frameon.toPythonBooleanOrNone()}," +
                        "clear=${clear.toPythonBooleanOrNone()}" +
                        ")"
            )
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy