Black Lives Matter. Please consider donating to Black Girls Code today.

Auto size for height does not work

I created a table image file with Plotly. But auto size for height does not work. As the following attached image, the waste space exists under the table. How can I fix that?

  • test.py
import pandas as pd
import plotly.graph_objects as go
import numpy as np

P_X_1 = ["Current assets", "Non-current assets", "Total", "Current liabilities", "Shareholders’ equity",
         "  Capital stock", "  Retained earnings", "  Net income for the year", "Total"]
P_X_2 = ["26,540", "1,072", "27,612", "2,975", "24,637",
         "20,000", "4,637", "(1,626)", "27,612"]

df = pd.DataFrame({"Account": P_X_1, "Amount(Thousand)": P_X_2})

fig = go.Figure(data=[go.Table(
    header=dict(values=df.columns, align='center', font_size=20,
                line_color='darkslategray', fill_color='lightskyblue'),
    cells=dict(values=df.values.T, align=['left', 'right'], font_size=10,
               line_color='darkslategray', fill_color='lightcyan')
)])

fig.update_layout(
    autosize=True,
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0,
        pad=0
    ),
    paper_bgcolor="LightSteelBlue",
)

fig.write_image("sample_table.png")

  • docker-compose.yml
version: "2.2"
services:
  plotly:
    build:
      context: .
      dockerfile: dockerfile-plotly
    image: plotly:latest
    container_name: plotly
    tty: true
    volumes:
      - "./src:/plotly/src"
  • dockerfile-plotly
FROM ubuntu:18.04

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        wget \
        xvfb \
        xauth \
        libgtk2.0-0 \
        libxtst6 \
        libxss1 \
        libgconf-2-4 \
        libnss3 \
        libasound2 && \
    mkdir -p /opt/orca && \
    cd /opt/orca && \
    wget --no-check-certificate https://github.com/plotly/orca/releases/download/v1.2.1/orca-1.2.1-x86_64.AppImage && \
    chmod +x orca-1.2.1-x86_64.AppImage && \
    ./orca-1.2.1-x86_64.AppImage --appimage-extract && \
    rm orca-1.2.1-x86_64.AppImage && \
    printf '#!/bin/bash \nxvfb-run --auto-servernum --server-args "-screen 0 640x480x24" /opt/orca/squashfs-root/app/orca "$@"' > /usr/bin/orca && \
    chmod +x /usr/bin/orca

RUN apt-get install -y --no-install-recommends  \
    python3-pip  \
    python3-setuptools \
    python3 \
    python3-dev \
    build-essential \ 
    libssl-dev \
    libffi-dev \
    libxml2-dev \
    libxslt1-dev \ 
    zlib1g-dev && \
    pip3 install pandas && \
    pip3 install plotly && \
    pip3 install psutil && \
    pip3 install requests

WORKDIR /plotly/src

CMD ["/bin/bash"]

I posted this question into stackoverflow.