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

KeyError if there is no ggsize #7

Closed
schakalakka opened this issue May 18, 2022 · 4 comments
Closed

KeyError if there is no ggsize #7

schakalakka opened this issue May 18, 2022 · 4 comments

Comments

@schakalakka
Copy link
Contributor

If I have a plot without ggsize like lp.ggplot(df, lp.aes(x='foo, y='bar')) + lp.geom_bar() then streamlit_letsplot throws an KeyError: 'ggsize' with a throwsback to File "C:\ProgramData\Anaconda3\envs\efleets39\lib\site-packages\streamlit_letsplot\__init__.py", line 24, in st_letsplot height=plot_dict["ggsize"]["height"]

Solution:
Adding lp.ggsize(500, 250) to the plot works.

@schakalakka
Copy link
Contributor Author

I am not sure why but now I am not able to get it working again but get instead another error:
generateStaticHtmlPage() - Exception: Trying to access top level value not marked as @ThreadLocal or @SharedImmutable from non-main thread even when ggsize is added.

If I remove the ggsize again it throws the KeyError first.

@randyzwitch
Copy link
Owner

Thanks for letting me know @schakalakka! I'm only using the default HTML generating method from LetsPlot, but maybe I have a version compatibility issue of some sort

@randyzwitch
Copy link
Owner

I think I see the issue here, I'm assuming too much from the library in terms of base data. I'll add a default, so that if ggsize isn't provided then it will default to something.

@alshan
Copy link

alshan commented Nov 2, 2022

Hi @randyzwitch ! I'm not familiar with the specifics of streamlit but nevertheless would like to share an info on one hidden feature of lets-plot related to the plot size:

If you define a data attribute "letsPlotPreferredWidth" (i.e. data-letsPlotPreferredWidth=500) in the plot's top container (i.e. iframe or, otherwise body), then the plot's width will be 500 px and plot height will be computed according to the plot's aspect ratio, which is either default or specified explicitly via ggsize().

I hope that might make easier for you to manage lets-pot size in streamlit apps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants