JetBrains / lets-plot

Multiplatform plotting library based on the Grammar of Graphics
https://lets-plot.org
MIT License
1.57k stars 51 forks source link

Unable to display or save graph when using geom_path #1168

Closed chameroy closed 2 months ago

chameroy commented 2 months ago

I've been trying out lets-plot through a Jupyter notebook on Windows 11.

I'm experiencing an issue that comes up when I use geom_path. I receive this error message both when trying to view a plot in Jupyter and when trying to save the image using ggsave, regardless of file format:

Exception: Internal error: NullPointerException : <no message>

Unfortunately, that's all I receive. Using geom_line in place of geom_path produces a graph, but not always with the desired result.

IKupriyanov-HORIS commented 2 months ago

Hi! Could you please provide an example? This will help us a lot.

chameroy commented 2 months ago

Sure. Here is an example of some code I've been trying to run:

plot = (
ggplot(core_10004_1A_1, aes("value", "depth_m", group="section_no")) +
    ggsize(150, 500) +
    geom_line() +
    facet_grid(x="channel", scales="free") +
    scale_y_reverse() +
    labs(x="Values", y="Depth (m)") +
    theme(legend_position="none")
)

ggsave(plot, "plot_test.png")

I've tried to get the resulting plot to show in Jupyter as well as save it locally in case this is a Jupyter issue. I get the same outcome in either case.

This is what I get when I use geom_line: plot_test

However, when I use geom_path, I get the error message I previously mentioned.

Running the same code using geom_path (and some minor tweaks due to library differences) using plotnine gives me closer to what I'm looking for: plot9_test

IKupriyanov-HORIS commented 2 months ago

Thanks! The code is totally fine. Could you please attach your data (core_10004_1A_1) if possible? Looks like it is the key for fixing the issue.

chameroy commented 2 months ago

Sure. Here it is. FYI, it's tab-delimited and has about 200,000 records. The original has close to 500,000, but it's too large for me to upload here. Hopefully, this should be good enough.

core_10004_1A_1.csv

IKupriyanov-HORIS commented 2 months ago

Thank you! I'v reproduced the issue. To workaround the problem add sampling='none' to geom_path(...).
Full code:

plot = (
ggplot(core_10004_1A_1, aes("value", "depth_m", group="section_no")) +
    ggsize(150, 500) +
    geom_path(sampling='none') +
    facet_grid(x="channel", scales="free") +
    scale_y_reverse() +
    labs(x="Values", y="Depth (m)") +
    theme(legend_position="none")
)
plot
chameroy commented 2 months ago

That works! Thanks!

You referred to this as a workaround. I assume that this is not intended behavior? Will this be addressed in a future version?

Thank you again!

IKupriyanov-HORIS commented 2 months ago

I assume that this is not intended behavior? Will this be addressed in a future version?

Definitely.