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

saving Vis images #335

Closed
deepikamittal opened this issue Mar 31, 2021 · 14 comments
Closed

saving Vis images #335

deepikamittal opened this issue Mar 31, 2021 · 14 comments
Labels
bug Something isn't working export Related to export

Comments

@deepikamittal
Copy link

I am using lux library for visualizations.
I have a Vis object and want to save the image.
I tried using save_as_html but i am getting the following error:
'Vis' object has no attribute 'save_as_html'.
How can i save the image?
Below attached the screenshot of the code.
Capture1

@dorisjlee
Copy link
Member

Hi @deepikamittal, Thank you for your question! Currently, the save_as_html feature can only be called on the dataframe. The reason why we did this is that when it is called on the dataframe, we export all the visualizations into a presentable HTML. But when you have a single Vis, it is much easier to save the visualization directly into HTML, PNG, or whichever format you like.

The easiest way to do this is by right-clicking on the figure and save the image as a PNG.
image
To export to other formats, you might want to first export your vis to the plotting code (e.g., print(num_v.to_code(language="altair"))) like this:
image
You can set the language as any one of matplotlib, altair or vegalite.

Then using the code written in those libraries, you should be able to save in whichever format you like. Here is an example of how you can export your visualization to code.

Let us know if this solves the problem for you.

@deepikamittal
Copy link
Author

Hi @dorisjlee . Thank you for your response.
I did export it to other format, i converted it to matplotlib code. but not able to see the visualisation. some error is coming.
Attaching the screenshot
Capture
Capture2

@dorisjlee
Copy link
Member

Hi @deepikamittal, Thanks for clarifying the details. To convert to matplotlib code, you can do print (num_v.to_matplotlib_code()). The to_matplotlib option that you were using turns it into an embeddable PNG, but it is not the code that can be used to generate the visualization.

@deepikamittal
Copy link
Author

Hi @dorisjlee . Thank you for your response. It is working now.

@deepikamittal
Copy link
Author

@dorisjlee - Also there is a difference in the visualizations created by lux and created by code through matplotlib. May be the scaling issue is there. Can you please help me on this.
Attaching the screenshot of both visualizations. Also the screenshot of the code which is in built used when we convert it to matplotlib code.

Capture
Capture1
Capture2

@dorisjlee
Copy link
Member

Hi @deepikamittal, Thanks for raising this issue. @caitlynachen will be taking a look at why the output code looks different from the code from the widget.

In addition, based on your feedback that to_matplotlib should return the matplotlib code, we fixed this in #359, so you should be able to use to_matplotlib in the latest release for Lux. You can install the latest release by doing:

pip install --upgrade lux-api

followed by the setup instructions.

@dorisjlee dorisjlee added the bug Something isn't working label Apr 19, 2021
@deepikamittal
Copy link
Author

Hi @dorisjlee . Thanks for the update.
Now i have implemented lux on jupyter notebook and its working correctly.
But while integrating the same code in flask, it is giving error.
' Lux dataframe object does not have attribute unique'.
Below attached is the screenshot. Please help me.
Inkedimage_LI

@deepikamittal
Copy link
Author

Hi @caitlynachen . Did you saw why the output visualization is different from the widget visualization. Please help me.
Thank you.

@dorisjlee
Copy link
Member

Hi @deepikamittal, Could you specify the code that you ran and the dataset that you used to reproduce the unique error? This will help us debug the issue that you are looking at.

@deepikamittal
Copy link
Author

Hi @dorisjlee , Please find attached the code. I am not able to attach the dataset. However, any dataset can e taken.

Capture

@deepikamittal
Copy link
Author

deepikamittal commented Apr 29, 2021 via email

@deepikamittal
Copy link
Author

Hi @dorisjlee, the images are saved at a particular path, however, integrating same thing on flask, i am not getting visualizations displayed on html. Is this some issue with lux or it a problem of html or flask. Please help me.
Below is the attached screenshot for reference.

image

@dorisjlee
Copy link
Member

Hi @deepikamittal, Thanks for attaching this info. It's a bit difficult to debug what went wrong, whether this is an issue with Lux or something that is an issue with Flask. Could you send me an email at dorisjunglinlee@gmail.com so that we hop on a call to debug this? I might be more help after understanding what your current setup is like and what might be causing the issue.

@dorisjlee dorisjlee added the export Related to export label Aug 1, 2021
@dorisjlee
Copy link
Member

Hi @deepikamittal, We're closing this for now, but please let us know if you run into any other issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working export Related to export
Projects
None yet
Development

No branches or pull requests

3 participants