-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2528 from ChristopherDavisUCI/samplev52
WIP: update to Vega-Lite 5.2
- Loading branch information
Showing
33 changed files
with
69,211 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
Grouped Bar Chart with xOffset | ||
------------------------------ | ||
Like :ref:`gallery_grouped_bar_chart`, this example shows a grouped bar chart. Whereas :ref:`gallery_grouped_bar_chart` used the ``column`` encoding channel, this example uses the ``xOffset`` encoding channel. This is adapted from a corresponding Vega-Lite Example: | ||
`Grouped Bar Chart <https://vega.github.io/vega-lite/examples/bar_grouped.html>`_. | ||
""" | ||
# category: bar charts | ||
import altair as alt | ||
import pandas as pd | ||
|
||
source = pd.DataFrame({"Category":list("AAABBBCCC"), | ||
"Group":list("xyzxyzxyz"), | ||
"Value":[0.1, 0.6, 0.9, 0.7, 0.2, 1.1, 0.6, 0.1, 0.2]}) | ||
|
||
alt.Chart(source).mark_bar().encode( | ||
x="Category:N", | ||
y="Value:Q", | ||
xOffset="Group:N", | ||
color="Group:N" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
Jitter Chart | ||
------------ | ||
In this chart, we encode the ``Cylinders`` column from the ``cars`` dataset in the ``y``-channel. Because most cars (all but seven) in this dataset have 4, 6, or 8 cylinders, the default presentation of this data would show most of the data concentrated on three horizontal lines. Furthermore, in that default presentation, it would be difficult to gauge the relative frequencies with which different values occur (because there would be so much overlap). To compensate for this, we use the ``yOffset`` channel to incorporate a random offset (jittering). This is adapted from a corresponding Vega-Lite Example: | ||
`Dot Plot with Jittering <https://vega.github.io/vega-lite/examples/point_offset_random.html>`_. | ||
""" | ||
# category: scatter plots | ||
import altair as alt | ||
from vega_datasets import data | ||
|
||
source = data.cars() | ||
|
||
alt.Chart(source).mark_point().encode( | ||
x='Horsepower:Q', | ||
y='Cylinders:O', | ||
yOffset='randomCalc:Q' | ||
).transform_calculate( | ||
randomCalc='random()' | ||
).properties( | ||
height=alt.Step(50) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
Slider Cutoff | ||
============= | ||
This example shows how to bind a variable parameter to a slider, and how to use the corresponding bound value to color data points. This example is based on an example from the Altair 4 documentation for Interactions, in which the interactivity was accomplished using a selection. The version below has been simplified significantly through the use of a variable parameter. Variable parameters were added in Altair 5. | ||
""" | ||
# category: interactive charts | ||
import altair as alt | ||
import pandas as pd | ||
import numpy as np | ||
|
||
rand = np.random.RandomState(42) | ||
|
||
df = pd.DataFrame({ | ||
'xval': range(100), | ||
'yval': rand.randn(100).cumsum() | ||
}) | ||
|
||
slider = alt.binding_range(min=0, max=100, step=1) | ||
cutoff = alt.parameter(bind=slider, value=50) | ||
|
||
alt.Chart(df).mark_point().encode( | ||
x='xval', | ||
y='yval', | ||
color=alt.condition( | ||
alt.datum.xval < cutoff, | ||
alt.value('red'), alt.value('blue') | ||
) | ||
).add_parameter( | ||
cutoff | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# flake8: noqa | ||
from .v4 import * | ||
from .v5 import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
"""Altair schema wrappers""" | ||
# flake8: noqa | ||
from .v4.schema import * | ||
from .v5.schema import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# flake8: noqa | ||
from .schema import * | ||
from .api import * | ||
|
||
from ...datasets import list_datasets, load_dataset | ||
|
||
from ... import expr | ||
from ...expr import datum | ||
|
||
from .display import VegaLite, renderers | ||
|
||
from .data import ( | ||
MaxRowsError, | ||
pipe, | ||
curry, | ||
limit_rows, | ||
sample, | ||
to_json, | ||
to_csv, | ||
to_values, | ||
default_data_transformer, | ||
data_transformers, | ||
) |
Oops, something went wrong.