cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to enable interactive Python matplotlib figures in DataBricks?

eabouzeid
New Contributor III

I want to make a matplolib interactive (I can zoom in/out, etc.) in databricks. This is achieved in Jupyter notebook by the following code:

 %matplotlib notebook

How to achieve this in databricks?

Thank you

10 REPLIES 10

Manoj12421
Valued Contributor II

Import โ€‹matplotlib.pylot

eabouzeid
New Contributor III

I wish it was that simple. "Import matplotlib.pyployt" allow you to plot but as static plots. I need an interactive plot.

Manoj12421
Valued Contributor II

This can help you to import and use use according to your needโ€‹

Anonymous
Not applicable

Hi @Elias Abou Zeidโ€‹ 

Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help. 

We'd love to hear from you.

Thanks!

Kaniz_Fatma
Community Manager
Community Manager

Hi @Elias Abou Zeidโ€‹, To enable interactive matplotlib figures in Databricks, you can use the %matplotlib magic command with the inline backend.

Try using

%matplotlib inline

at the top and press Enter. This will enable the inline backend for matplotlib and allow you to display matplotlib figures directly in the notebook.

Hi @Elias Abou Zeidโ€‹,

Did you have time to test @Kaniz Fatmaโ€‹ recommendation? do you still need help? please let us know

I have tried %matplotlib inline , it does not work the plot remains static

amu
New Contributor II

Hi there, while facing a similar issue we switched to Altair python library and it works great with Databricks. (other options can be Bokeh or Plotly).

Kaniz_Fatma
Community Manager
Community Manager

Hi @Elias Abou Zeidโ€‹, Hi (Customer)โ€‹, Thank you for your question! To assist you better, please take a moment to review the answer and let me know if it best fits your needs.

Please help us select the best solution by clicking on "Select As Best" if it does.

Your feedback will help us ensure that we are providing the best possible service to you. Thank you!

eabouzeid
New Contributor III

Thanks @Andrii Muzychukโ€‹.  I already have a complex interactive plot function developed using matplotlib under jupyter. I imported to Databricks, but unfortunately for now I have not figured out a way to make it work interactively in DataBricks. Instead of re-writing it from scratch is there a way to convert a matplotlib figure to Altair ( I have tried plotly mpl_to_plotly but it does not work properly for my plot).?

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group