cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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 

 

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.