cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Value Labels fail to display in Databricks notebook but they are displayed ok in Jupyter

bluetail
Contributor

import matplotlib.pyplot as plt

import seaborn as sns

import pandas as pd

import numpy as np

prob = np.random.rand(7) + 0.1

prob /= prob.sum()

df = pd.DataFrame({'department': np.random.choice(['helium', 'neon', 'argon', 'krypton', 'xenon', 'radon', 'oganesson'],

1000, p=prob),

'left': np.random.choice(['yes', 'no'], 1000)})

with this code, I can see the value labels in my Anaconda's Jupyter however, they are not displayed in my Databricks notebook? any idea how to fix?

import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
 
prob = np.random.rand(7) + 0.1
prob /= prob.sum()
df = pd.DataFrame({'department': np.random.choice(['helium', 'neon', 'argon', 'krypton', 'xenon', 'radon', 'oganesson'],
                                                  1000, p=prob),
                   'left': np.random.choice(['yes', 'no'], 1000)})
sns.set_style('white')
filter = df['left'] == 'yes'
g = sns.catplot(data=df[filter], kind='count', y='department', palette='mako_r',
            order=df[filter]['department'].value_counts(ascending=True).index)
for ax in g.axes.flat:
    ax.bar_label(ax.containers[0], fontsize=12)
    ax.margins(x=0.1)
plt.tight_layout()
plt.show()

the bar_label attributes are used in matplotlib.pyplot version 3.4.2.

I am using ML runtime 7.3. how can I upgrade?

thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

austin_ford
New Contributor III
New Contributor III

@Maria Bruevich​ MLR 7.3 has matplotlib version 3.1.3 (you can see the contents here). If you upgrade to MLR 9.0, you will have matplotlib 3.4.2 and should not encounter any errors.

Hope that helps!

View solution in original post

4 REPLIES 4

Anonymous
Not applicable

Hello again! Thanks for asking. We'll wait for the community to respond before we circle back around.

We appreciate your patience. 🙂

Anonymous
Not applicable

You need to use the display function for plotting visualizations.

Here are the docs:

https://docs.databricks.com/notebooks/visualizations/charts-and-graphs-python.html

https://docs.databricks.com/notebooks/visualizations/charts-and-graphs-python.html

To upgrade your runtime, just choose a different rundown from the cluster creation dropdown window.

austin_ford
New Contributor III
New Contributor III

@Maria Bruevich​ MLR 7.3 has matplotlib version 3.1.3 (you can see the contents here). If you upgrade to MLR 9.0, you will have matplotlib 3.4.2 and should not encounter any errors.

Hope that helps!

Anonymous
Not applicable

@Maria Bruevich​ - Do either of these answers help? If yes, would you be happy to mark one as best so that other members can find the solution more quickly?

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.