Skip to content

PlotlyKt not working with Kotlin Jupyter notebook #108

@parrotcar00

Description

@parrotcar00

Plotly kt not working in Kotlin Jupyter notebook in IntelliJ Ultimate version Build #IU-243.23654.153.
Looks like other people are also seeing this issue:
https://youtrack.jetbrains.com/issue/KTNB-578/plotly.kt-plots-are-not-rendered-in-notebook

Here's the code that I tried:

import space.kscience.plotly.PlotlyIntegration

val integration = PlotlyIntegration()

USE(integration.getDefinitions(notebook).first())
#%%
Plotly.jupyter.notebook()
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"
    }
    plot("below", config = plotConfig, renderer = renderer) {
        traces(trace1, trace2)
        layout {
            title = "The plot below"
            xaxis.title = "x axis name"
            yaxis.title = "y axis name"
        }
    }

}

These are the dependencies I have defined in my project build.gradle.kts:

implementation("space.kscience:plotlykt-jupyter:0.7.1.1")
implementation("space.kscience:plotlykt-server:0.7.1.1")

When I run the above code, I don't get any plot output. I just get a truncated output of "A custom header"

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions