I have a legend with far too many values, i have implemented a scroll function however i cannot figure out how to properly size my chart and legend
This is what i have, and when i run this just on my computer not pushing to streamlit the scroll bar works but this displays the entire legend on streamlit everytime i try to change the size i continue with similar outputs. This is an image of my webpage right now, as you can see the legend continues down the page, i need to make it cut off so i can use the scroll function:
fig1 = plt.figure(figsize=(7, 3))
axx = fig.add_axes([0.1, 0.6, 0.3, 0.3])
p1 = volcanos["Country"].value_counts()
fig1, axx = plt.subplots()
axx.pie(p1, labels=p1.keys(), autopct='%1.1f%%',
shadow=True, startangle=90)
legend = axx.legend(loc="upper left", bbox_to_anchor=(1.02, 0, 0.07, 1))
# pixels to scroll per mousewheel event
d = {"down" : 30, "up" : -30}
def func(evt):
if legend.contains(evt):
bbox = legend.get_bbox_to_anchor()
bbox = Bbox.from_bounds(bbox.x0, bbox.y0+d[evt.button], bbox.width, bbox.height)
tr = legend.axes.transAxes.inverted()
legend.set_bbox_to_anchor(bbox.transformed(tr))
fig1.canvas.draw_idle()
fig1.canvas.mpl_connect("scroll_event", func)
st.pyplot(fig1)