visionforge/plotly/examples/notebooks/.ipynb_checkpoints/plotlykt-demo-checkpoint.ipynb

2.2 KiB

In [ ]:
%use plotly
In [ ]:
import kotlin.math.*

val x1 = (0..100).map { it.toDouble() / 100.0 }
val y1 = x1.map { sin(2.0 * PI * it) }
val y2 = x1.map { cos(2.0 * PI * it) }

val trace1 = Trace(x1, y1) { name = "sin" }
val trace2 = Trace(x1, y2) { name = "cos" }

Plotly.page { renderer ->
    val plotConfig = PlotlyConfig{
        responsive = true
        imageFormat = "svg"
    }        
    h1 { +"A custom separator" }
    hr()
    plot("below", renderer = renderer) {
        traces(trace1, trace2)
        layout {
            title = "The plot below"
            xaxis.title = "x axis name"
            yaxis.title = "y axis name"
        }
    }

}
In [ ]: