Get help from the marimo community

Updated last month

Automatically expanding the output of a cell

At a glance

The community members discuss a use case where a notebook cell displaying a map has a portion of the map hidden, and the only way to see the full extent is to click the "Expand output" button. They explore various solutions, such as adjusting the HTML code to add a border and setting a maximum height, but these do not fully resolve the issue. One community member suggests changing the height on the library being used to display the map, but this does not seem to have an effect. Eventually, the community members find that adjusting the size and then clicking the "Toggle App View" button renders the map correctly, and setting a height of 500 pixels allows the full map to be displayed without a scroll bar.

Can I add code to a cell that, when executed, is equivalent to clicking the "Expand output" button on the right side of the cell?
A
C
M
13 comments
No, that is not possible today. What is the use case for this?
@Akshay When the notebook cell creating my map evaluates, a small portion of the map is invisible and a scroll bar appears. The only way to see the full extent of the map is to click the expand output button which is unfortunate.
Wonder if the truncation has anything to do with switching to HTML to add a boundary around the cell. This is the code snippet.
mo.Html(
f"""
<div style='border: 1px solid; ; margin: 5px'>
{mo.as_html(m)}
</div>
"""
)
you could remove the margin, or set a max-height: e.g. 500px
Neither brings the map into full view unfortunately.
Actually the max-height property doesn't seem to have any impact on the resulting height
Can you change the height on the library you are using?
@Myles Scolnick good call. I'll look into it. I bet the answer is yes.
@Myles Scolnick interestingly enough, changing the height on the Leafmap side is not changing the height of the resulting map
Actually I take that back. When I adjust the size and rerun the cell, the map size does not change. BUT if I hit the Toggle App View button, it renders correctly. And then when I return to the notebook, it then is displayed at the correct size.
Anyhoo, I got to what I wanted. Looks like at a height of 500 px, it'll still render the entire map without loading a scroll bar. Appreciate your feedback!
Add a reply
Sign up and join the conversation on Discord