How to Control Sweetviz Report Browser Display with Python

This quick tutorial shows how to customize how Sweetviz reports open and display using show_html() parameters. For a complete introduction to automated exploratory data analysis, see our Automated Exploratory Data Analysis with Sweetviz in Python guide.

The Problem

By default, Sweetviz automatically opens reports in your browser immediately after generation, which works fine for interactive analysis. But this behavior causes issues in automated scripts, scheduled jobs, or when generating multiple reports in sequence. Your browser gets flooded with tabs, or worse, the script hangs waiting for user interaction. When sharing reports with colleagues or deploying analysis pipelines, you need control over whether and how the HTML files open.

The Solution

The show_html() method accepts parameters that control report display behavior. The open_browser parameter determines whether the report opens automatically, while layout controls the visual arrangement.

To generate a report without opening your browser:

 
import sweetviz as sv
import seaborn as sns

df = sns.load_dataset('titanic')
report = sv.analyze(df)
report.show_html('titanic_report.html', open_browser=False)

Setting open_browser=False saves the HTML file to disk without launching it. You can open it manually later, send it to colleagues, or process it programmatically. This is essential for automated workflows where you generate reports on a schedule or as part of a larger pipeline.

For custom report layouts, use the layout parameter:

 
report = sv.analyze(df)
report.show_html('titanic_vertical.html', 
                 open_browser=True,
                 layout='vertical')

control sweetviz report browser display 

The layout parameter accepts ‘widescreen’ (default) or ‘vertical’. Widescreen works well for large monitors and side-by-side comparisons, while vertical suits narrow displays and sequential reading. Choose based on your viewing environment and how you expect others to consume the report.

A Few Tips

When generating multiple reports in a loop, always set open_browser=False to prevent browser tab overload. If you need to review one specific report, you can set it to True just for that iteration. The HTML files are self-contained and portable, meaning you can email them, host them on internal servers, or archive them for documentation without any dependencies. Reports work offline once generated, so recipients don’t need Python or Sweetviz installed. For production environments, consider adding timestamps to filenames to avoid overwriting previous analyses.

Conclusion

The show_html() parameters give you precise control over report generation and display. Use open_browser=False for automated workflows and choose the layout that matches your presentation needs.

Leave a Reply

Your email address will not be published. Required fields are marked *