Search code examples
pythongoogle-colaboratory

How to zoom in graphs in colab


I am able to get an interactive graph in Google colab with the code:

!pip install mpld3
%matplotlib notebook
mpld3.enable_notebook()
df.plot(x = 'Time', y = 'Data')

but the plot is really small. In R you can click on the graph and it will reopen in the new window. Is there a similar method to do this with colab? Thanks.


Solution

  • google-colaboratory does not provide any native data visualization, but it does support a variety of third-party visualization packages (matplotlib, altair, bokeh, plotly, etc.) You should look in the documentation of the library you are using to see how to adjust the size of figures.

    In your example, you appear to be using pandas matplotlib plotting API. As the documentation mentions, you can adjust plot sizes with the figsize argument:

    df.plot(x='Time', y='Data', figsize=(16, 10))