Status Codes

Create a treemap for visualizing status code on two levels: the status category (100, 200, 300, 400, 500) and the status codes’ actual values (200, 301, 404, etc.)

source

status_codes

def status_codes(
    status_list,
    height:int=600,
    width:NoneType=None,
    template:str='none',
    title:str='Status Codes',
    subtitle:NoneType=None
):

Create a treemap to visualize a list of status codes.

Type Default Details
status_list A collection of HTTP status codes
height int 600
width NoneType None
template str none Name of template to use for the chart. Available themes:
ggplot2, seaborn, simple_white, plotly, plotly_white, plotly_dark,
presentation, xgridoff, ygridoff, gridon, none |
title | str | Status Codes | The title of the figure. You can use/include the following HTML tags in

the title: <a>, <b>, <br>, <i>, <sub>, <sup> | | subtitle | NoneType | None | The subtitle of the figure, by default 70% of the font size of the title | | Returns | | | |

Visualize the distribution of a list of status codes

codes = pd.read_csv("data/status_codes.csv")
codes
status
0 200
1 200
2 200
3 200
4 200
... ...
414398 200
414399 200
414400 200
414401 200
414402 200

414403 rows × 1 columns

status_codes(codes["status"])

Change the template with the template parameter

status_codes(codes["status"], template="seaborn")
status_codes(codes["status"], template="plotly_dark")

Change the dimensions of the charts with width and height

status_codes(codes["status"], width=700, height=700, subtitle="example.com")

Modify the title of the chart, and make use of various HTML tags <a>, <b>, <br>, <i>, <sub>, <sup>

website = "MyWebsite.com"
title = f'Error Codes distribution <b>400</b> and <b>500</b><br>clickable: <i><a href="https://mywebsite.com">{website}</i> – April 3, 2023'

status_codes(
    codes.query("status >= 400")["status"],
    title=title,
    height=700,
    width=1300,
    template="ggplot2",
)