Skip to content

Commit

Permalink
Merge pull request #2 from ChiaLingWeng/wengchia
Browse files Browse the repository at this point in the history
[Doc] Update User Guide: Add sort legend using EncodingSortField example
  • Loading branch information
ChiaLingWeng authored Oct 5, 2023
2 parents 5e838f3 + 1bab8fd commit 20e33dc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/user_guide/encodings/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,18 @@ While the above examples show sorting of axes by specifying ``sort`` in the
Here the y-axis is sorted reverse-alphabetically, while the color legend is
sorted in the specified order, beginning with ``'Morris'``.

Here is another example using :class:`EncodingSortField` class to sort color legend.
By specifying ``field``, ``op`` and ``order``, the legend can be sorted based on chosen data field.

.. altair-plot::

alt.Chart(barley).mark_rect().encode(
alt.X('mean(yield):Q').sort('ascending'),
alt.Y('site:N').sort('x'),
color=alt.Color('site',
sort=alt.EncodingSortField(field='yield', op='mean', order='ascending'))
)

Datum and Value
~~~~~~~~~~~~~~~

Expand Down

0 comments on commit 20e33dc

Please sign in to comment.