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

3.6 MiB

In [1]:
%use @file[plotly-experimental.json]
import kotlin.math.*
In [2]:
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" }

val fragment = Plotly.fragment { renderer ->
    plot("above", renderer = renderer) {
        traces(trace1, trace2)
        layout {
            title = "The plot above"
            xaxis.title = "x axis name"
            yaxis.title = "y axis name"
        }
    }
    hr()
    h1 { +"A custom separator" }
    hr()
    div {
        plot(renderer = renderer) {
            traces(trace1, trace2)
            layout {
                title = "The plot below"
                xaxis.title = "x axis name"
                yaxis.title = "y axis name"
            }
        }
    }
}
fragment
Out[2]:

A custom separator


In [3]:
Plotly.plot {
    traces(trace1, trace2)
    layout {
        title = "The plot below"
        xaxis.title = "x axis name"
        yaxis.title = "y axis name"
    }
}
Out[3]:
In [6]:
HTML("<script>console.info(Plotly)</script>")
Out[6]:
In [5]:
Plotly.plot {
    traces(trace1, trace2)
    layout {
        title = "The plot below"
        xaxis.title = "x axis name"
        yaxis.title = "y axis name"
    }
}
Out[5]:
In [ ]: