Published in


Python Quick Tip: Auto-Generate Visualization Code

Getting the syntax right for data visualizations in Python can be tricky. Mito is a Python package that allows you to generate Python visualization code…without coding!

Here is a demo video:

Here are the commands to install Mito in Jupyter Lab:

python -m pip install mitoinstaller
python -m mitoinstaller install

Then open Jupyter Lab and call the Mitosheet

import mitosheet

Complete instructions can be found on the Mito website under “docs.”

Mito provides an interactive environment for configuring your visualizations. Before you create your charts, you can use the full spreadsheet interface to clean and wrangle your data. These features include, pivoting, merging, filtering, sorting, spreadsheet functions and more!

from Author

Mito is built using the Plotly graphing library. Plotly is the best Python package for building interactive visualizations. When paired with Mito, you can access the power of Plotly without needing to write the code yourself. As you create your chart in Mito, the Plotly code will automatically generate in the code cell below. All you have to do is click “Copy Graph Code” and paste it into any code cell.

The diagram below shows where you can open the graphing menu inside Mito and what the graphing interface looks like. The button to copy the graph code is at the bottom of the screen.

Below is the auto-generated code that Mito creates from the graph above:

# Import plotly and create a figure
import plotly.graph_objects as go
fig = go.Figure()
# Add the histogram traces to the figure
for column_header in ['Style']:
fig.add_trace(go.Histogram(x=ramen_ratings[column_header], name=str(column_header)))
# Update the layout
# See Plotly documentation for customizations:
title="Style frequencies",

Also in the image, you can see some of the other spreadsheet functionality Mito offers:

  • Importing and exporting CSVs and Excel files
  • Adding and deleting columns
  • Pivot Tables
  • Merging DataFrames Together
  • Filtering and Sorting
  • Filling null values
  • Deduplicating datasets
  • Summary Statistics
  • And more!

One of the great parts of the autogenerated code is that it makes sharing your analysis very easy. Many data scientists use Mito as a communication tool. They will record their steps in Mito and then send the generated code to a colleague who can put it into production.

The graphs from Mito are also used in presentations. You can download any of the charts as a PNG, making it easy to plant them into a powerpoint, email, or document.

Mito is an intelligent way to make charts quickly, without needing to constantly go to the internet to look up the correct syntax. Your finished analysis looks the same, but you don’t need to write all the code yourself!

I hope you find this tool helpful :)



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jake from Mito

Jake from Mito

Exploring the future of Python and Spreadsheets