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: 

Seaborn plot display in Databricks

SergeyIvanchuk
New Contributor

I am using Seaborn version 0.7.1 and matplotlib version 1.5.3

The following code does not display a graph in the end. Any idea how to resolve ? (works in Python CLI on my local computer)

import seaborn as sns
sns.set(style="darkgrid")
tips = sns.load_dataset("tips")
color = sns.color_palette()[2]
g = sns.jointplot("total_bill", "tip", data=tips, kind="reg",
                  xlim=(0, 60), ylim=(0, 12), color=color, size=7)
import matplotlib.pyplot as plt
display(plt.show())

Instead of an image, I get the words "None" shown

4 REPLIES 4

chrislill
New Contributor II

Duplicate of https://forums.databricks.com/questions/13369/databricks-wont-display-new-plot-seaborn.html. This confused me for a bit as well.

If you create the figure and axes in matplotlib then seaborn will automatically add the plot to it. The figure can then be displayed in the databricks notebook.

fig, ax = plt.subplots()
sns.jointplot("total_bill", "tip", data=tips, kind="reg", xlim=(0, 60), ylim=(0, 12),
          color=color, size=7)
display(fig)

migueldhr
New Contributor II

Try changing the last line in your code:

display(plt.show())

to

display(g.fig)

My results doing that:

help-databircks.png

DavidLin
New Contributor III

As of DBR 6.4+, %matplotlib inline is supported, and you no longer need to call display().

AbbyLemon
New Contributor II

I found that you create a similar comparison plot as what you get from seaborn by using the display(sparkdf) and adding multiple columns to the 'Values' section while creating a 'Scatter plot'. You get to the 'Customize Plot' by clicking on the icon of the bar chart, then the 'Plot Options...' button will show up.

displaydf.pngplotoptions.png 

 

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!