1

I wrote a function to visualize python graphs using 'Seaborn' & 'Matplotlib' & I have been trying to store the output in HTML files. Is there a way to do so? I looked online but couldn't find any sources that talk about storing the visualizations of these libraries in HTML.

# Importing libraries
from statistics import correlation
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt



def dynamic_manual_eda(df):
    
    # Visualizing missing values
        miss_viz=sns.heatmap(df.isnull(),yticklabels=False,cbar=False,cmap='viridis')
        
        miss_plot=miss_viz.write_html("templates/missing_viz.html")
        
        return miss_plot  

eda_file = pd.read_csv('C:/Users/Churn_bank.csv')

dynamic_manual_eda(eda_file)


The error I get here is - '**AttributeError: 'AxesSubplot' object has no attribute 'write_html**''

NOTE: The visualizations should be stored only in HTML files. That's the requirement.

  • 3
    you can save `matplotlib` & `seaborn` plots to an image file and load it from an html template, but you're probably looking for a web-based plotting library like `altair`, `bokeh`, or `plotly`. – aorr Nov 02 '22 at 15:48
  • You can also print matplotlib (including seaborn) to svg which is probably what you want if targeting the web. – mwaskom Nov 03 '22 at 00:35

0 Answers0