lets-plot-kotlin icon indicating copy to clipboard operation
lets-plot-kotlin copied to clipboard

How to not connect null values in line plot (geomLine)?

Open parrotcar00 opened this issue 11 months ago • 2 comments

I have this plot: val testData = mapOf( "x" to listOf(1, 2, 3, 4, 5, 6), "y" to listOf(4, null, 6, null, 2, 3), ) letsPlot(testData) { x = "x"; y = "y" } + ggsize(1300, 300) + geomLine()

As you can see in the plot produced, the line plot is connecting the last non-null value to the next non-null value. Is there a way that I can instruct it to not draw connecting lines when it comes across null values in y axis data?

I'm trying to make it more obvious in the plot where the values are missing or NaN.

Image

parrotcar00 avatar Jan 26 '25 00:01 parrotcar00

Thinking some more about this, if the current behavior is the intended behavior, maybe we can add a config option to only draw lines between non-null values or there can be a new geom like geomDiscontinuousLine() that has this behavior?

parrotcar00 avatar Jan 26 '25 17:01 parrotcar00

Hi, according to gpplot2 docs - Missing value handling - geom_line indeed skips over missing values. So it seems LP should probably have this behavior by default as well. And also we can provide an option to interpolate missing value (not present in ggplot2 for some reason).

alshan avatar Jan 27 '25 20:01 alshan