:orphan:
:html_theme.sidebar_secondary.remove:
.. This document is auto-generated by the altair-gallery extension. Do not modify directly.
.. _gallery_line_with_log_scale:
Line Chart with Logarithmic Scale
---------------------------------
How to make a line chart on a `Logarithmic scale `_.
.. altair-plot::
:remove-code:
import altair as alt
from vega_datasets import data
source = data.population()
alt.Chart(source).mark_line().encode(
x='year:O',
y=alt.Y(
'sum(people)',
scale=alt.Scale(type="log") # Here the scale is applied
)
)
.. tab-set::
.. tab-item:: Method syntax
:sync: method
.. code:: python
import altair as alt
from vega_datasets import data
source = data.population()
alt.Chart(source).mark_line().encode(
x='year:O',
y=alt.Y('sum(people)').scale(type="log")
)
.. tab-item:: Attribute syntax
:sync: attribute
.. code:: python
import altair as alt
from vega_datasets import data
source = data.population()
alt.Chart(source).mark_line().encode(
x='year:O',
y=alt.Y(
'sum(people)',
scale=alt.Scale(type="log") # Here the scale is applied
)
)