nilsinelabore
nilsinelabore

Reputation: 5135

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.

Upvotes: 1

Views: 11654

Answers (2)

Sachin
Sachin

Reputation: 277

mpld3 is an interactive module for matplotlib. You can understand its working here.

A simplifies answer to the same could be

import matplotlib.pyplot as plt
import mpld3
from mpld3 import plugins

fig, ax = plt.subplots()
ax.grid(True, alpha=0.3)

plt.plot(x, y)
mpld3.display()

where x & y are arrays of corresponding axis values.

Upvotes: 1

jakevdp
jakevdp

Reputation: 86443

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))

Upvotes: 2

Related Questions