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!
If the results are different, you can use Kernel -> Change Kernel in the Jupyter notebook menu to change to a kernel with a working Altair version. If that's not the case, then it is likely that you have inadvertently enabled a different renderer in one of the notebooks, for example by running alt. renderers.
The fundamental chart representation output by Altair is a JSON string format; you can save a chart to a JSON file using Chart. save() , by passing a filename with a . json extension.
Altair is a declarative statistical visualization library for Python, based on Vega and Vega-Lite. Altair offers a powerful and concise visualization grammar that enables you to build a wide range of statistical visualizations quickly.
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
)
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