Hello Streamlit experts!
Do you know if there is a way to make two plotly tables closer together?
Code and Screenshot attached.
Thank you so much for your help!
Hello Streamlit experts!
Do you know if there is a way to make two plotly tables closer together?
Code and Screenshot attached.
Thank you so much for your help!
Hi @elcade
I was able to get them closer together with insight from a Ploty community forum thread. In fig.update_layout
, I set the values of all the margin
parameters to 0 and then varied the space between the tables by adjusting the height
parameter.
Here’s a working example:
import streamlit as st
import plotly.graph_objects as go
fig = go.Figure(data=[go.Table(header=dict(values=['A Scores', 'B Scores']),
cells=dict(values=[[100, 90, 80, 90], [95, 85, 75, 95]]))])
separation = st.sidebar.slider("Separation", min_value=10, max_value=500)
fig.update_layout(
width=1400,
height=separation,
margin=dict(
l=0,
r=0,
b=0,
t=0
)
)
st.plotly_chart(fig)
fig = go.Figure(data=[go.Table(header=dict(values=['C Scores', 'D Scores']),
cells=dict(values=[[23, 90, 80, 90], [95, 85, 75, 95]]))])
fig.update_layout(
width=1400,
height=100,
margin=dict(
l=0,
r=0,
b=0,
t=0
)
)
st.plotly_chart(fig)
Here’s the output:
Does this help with your use-case?
Best,
Snehan
Yes! this is awesome.
Thank you @snehankekre!
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.