display images in databricks

Abhishek Gaikwad 191 Reputation points
2021-02-27T08:15:14.89+00:00

I am trying to write a plot to datalake and then later display the plot. However the plot does not get displayed. Any suggestions.

import matplotlib.pyplot as plt
plt.scatter(x=[1,2,3], y = [2,4,3])
plt.savefig('/dbfs/mnt/Datalake3/plot/Figure22.png')



displayHTML("/dbfs/mnt/Datalake3/plot/Figure22.png")
Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,030 questions
0 comments No comments
{count} votes

Accepted answer
  1. Saurabh Sharma 23,776 Reputation points Microsoft Employee
    2021-03-02T05:19:12.203+00:00

    @Abhishek Gaikwad Thanks for using Microsoft Q&A !!

    You can use imshow() function of Matplotlib to render images out of the generated array using the function like below -

    import matplotlib.pyplot as plt  
    import matplotlib.image as mpimg  
    img = mpimg.imread('/dbfs/databricks/plot/Figure22.png')  
    imgplot = plt.imshow(img)  
    

    Here is the results screenshot for your reference.
    73190-image.png

    Also, refer to the matplotlib documentation for more details.

    ----------

    Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful