I am rendering Altair plots in Jupyter notebook (not JupyterLab) using:
alt.renderers.enable('notebook')
And everything works fine, however the plots are often small relative to the width of my Jupyter notebook.
If I expand the width of the notebook to 100% of my screen using:
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
Altair plots don't scale accordingly (they stay the same size).
Is there any way to scale the size of rendered plots (i.e., make them bigger) while still keeping them within the notebook?
Thanks!
There is no way to automatically scale Altair charts to the size of the browser window. The size of charts is controlled by the view configuration and/or the width
and height
properties in the chart specification; for example:
import altair as alt
from vega_datasets import data
cars = data.cars()
alt.Chart(cars).mark_point().encode(
x='Horsepower',
y='Miles_per_Gallon',
color='Origin'
).properties(
width=800,
height=300
)