How to print any plot on Databricks?

Siddhesh Bhurke 46 Reputation points
2020-11-05T12:38:53.25+00:00
%matplotlib inline
corr = df.corr()
f, ax = plt.subplots(figsize=(11, 9))
ax = sns.heatmap(
    corr, 
    vmin=-1, vmax=1, center=0,
    cmap=sns.diverging_palette(20, 220, n=500),
    linewidths=.50, 
    cbar_kws={"shrink": .7},
    square=True
)

ax.set_xticklabels(
    ax.get_xticklabels(),
    rotation=45,
    horizontalalignment='right'
);
plt.show()

This code it is does not give any plot display on azure data bricks, only displays

<Figure size 1100x900 with 2 Axes>

whereas the same code worked fine and displayed a corr plot earlier, not sure whats going wrong here. I get the same output even when I try this.

mask = np.triu(np.ones_like(corr, dtype=bool))

f, ax = plt.subplots(figsize=(11, 9))

cmap = sns.diverging_palette(20, 220, as_cmap=True)

sns.heatmap(corr, mask=mask, cmap=cmap, vmax=0.3, center=0,
            square=True, linewidths=.1, cbar_kws={"shrink": .7})
plt.show()
Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,222 questions
{count} votes

Accepted answer
  1. PRADEEPCHEEKATLA 90,231 Reputation points
    2020-11-06T05:42:50.437+00:00

    Hello @Siddhesh Bhurke ,

    Welcome to the Microsoft Q&A platform.

    It looks like an issue with the matplotlib modules above 3.3.0.

    To know the exact reason, I would suggest you to report here: https://github.com/matplotlib/matplotlib/issues

    As per the test from our end, you will experience the following error message with the matplotlib modules above 3.3.0.

    37890-image.png

    If you have installed matplotlib modules above 3.3.0, I would suggest you to use matplotlib modules below 3.2.2.

    37926-image.png

    Once you have installed matplotlib==3.2.2, I'm able to successfully display the plot.

    37903-image.png

    Hope this helps. Do let us know if you any further queries.

    ------------

    • Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.