In Google Colaboratory notebook I have a loop that generates a lot of charts...my problem is that it does not display the full output nicely. Instead it shows it inside a cell with a scroll bar. I want to show the full result instead of scrolling up and down...but there doesn't seem to be any setting in Google Colaboratory that allows that. I was wondering if anyone knows if it's possible to change the cell height of the result? Thanks!
Now, the snippets are available in any colab notebook you use. Just click the <> icon on sidebar, search for your snippet name and click Insert. The code will be inserted into a new cell.
I just realized that you can go to the bottom left corner of the screen and click the button (if you hover over you see that it says "command palette"), then search "fullscreen" you find the button that says view output "fullscreen".
As shown in Google Colab's "Keyboard shortcuts" window, the shortcut is "⌘/Ctrl+M -".
I managed to automate this for all cells in the entire Notebook.
Just create a cell with the following code and execute it, all the other cells in the Notebook will be automatically height-adjusted up to 5000px:
# Avoids scroll-in-the-scroll in the entire Notebook
from IPython.display import Javascript
def resize_colab_cell():
display(Javascript('google.colab.output.setIframeHeight(0, true, {maxHeight: 5000})'))
get_ipython().events.register('pre_run_cell', resize_colab_cell)
(It's just a variation of the answers in this thread and a tip from here)
There's an answer from a dev here. Note that the display(...)
command must be included in every cell you wish to extend the max height of (unless maybe you write some extra javascript). Quote below.
An example in Python:
from IPython.display import Javascript
display(Javascript('''google.colab.output.setIframeHeight(0, true, {maxHeight: 5000})'''))
for i in range(200):
print(i)
This may help.
from IPython.display import Javascript
display(Javascript("google.colab.output.resizeIframeToContent()"))
Try this:
from IPython.display import HTML
display(HTML('''
<style>
pre {
white-space: normal;
}
</style>
'''))
print('x ' * 200)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With