Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facet grid truncated in jupyter #28

Closed
patonw opened this issue Jul 4, 2020 · 3 comments
Closed

Facet grid truncated in jupyter #28

patonw opened this issue Jul 4, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@patonw
Copy link

patonw commented Jul 4, 2020

Playing around with the mtcars dataset, un-faceted plots are displayed correctly in jupyter via the kotlin-jupyter kernel:
2020-07-04-153159_745x489_scrot

When trying to facet by cylinder or any integer column, the image is truncated to varying degrees based on my window size. Regardless, part of the data, axes or guide is always missing:

2020-07-04-153222_735x381_scrot

2020-07-04-153844_1085x480_scrot

2020-07-04-154313_925x682_scrot

Notebook code for reference:

%use lets-plot, kotlin-statistics

@file:Repository("https://jitpack.io")
@file:DependsOn("de.mpicbg.scicomp:krangl:0.11")

import krangl.*

val df = DataFrame.readCSV("data/mtcars.csv")

fun DataCol.toList() = when (this) {
    is DoubleCol -> asDoubles()
    is IntCol -> asInts()
    is LongCol -> asLongs()
    is StringCol -> asStrings()
    else -> null
}?.toList()

fun DataFrame.toMap() = this.cols
    .map { it.name to it.toList() }
    .filter { it.second != null }
    .toMap()

df["cyl"].asInts().toSet()

val plot = lets_plot(df.toMap()){x = "disp"; y = "hp" }

(
    lets_plot(df.toMap()){x = "disp"; y = "hp" }
        + geom_point() { size="mpg"; color = "cyl"}
        + scale_color_continuous("red", "blue", guide = guide_legend(ncol=1))
        + facet_grid("cyl")
)

(
    ggplot(df.toMap()){x = "disp"}
        + geom_histogram()
        + facet_grid("gear", "cyl")
)
@alshan
Copy link
Collaborator

alshan commented Jul 6, 2020

I can suggest using ggsize(w,h) function to adjust the overall plot size like: lets_plot(..) + ggsize(500, 200).

@alshan alshan added the enhancement New feature or request label Jul 14, 2020
@alshan
Copy link
Collaborator

alshan commented Jul 14, 2020

Would be nice to limit the plot size to the available client width.

@alshan
Copy link
Collaborator

alshan commented Mar 23, 2021

In v1.3.0 the output should not exceed width of the container element (unless the plot size is overridden by the ggsize() function).
Please checkout v1.3.0.

@alshan alshan closed this as completed Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants