[query/ggplot] Shows legend group for single-value columns - #13113
Merged
danking merged 1 commit intoJun 9, 2023
Conversation
iris-garden
force-pushed
the
query/ggplot/single-value-legend-group
branch
from
May 24, 2023 17:21
d5fa702 to
fb456f5
Compare
iris-garden
force-pushed
the
query/ggplot/single-value-legend-group
branch
from
June 5, 2023 14:33
fb456f5 to
2231efe
Compare
iris-garden
force-pushed
the
query/ggplot/single-value-legend-group
branch
from
June 5, 2023 20:01
2231efe to
f131495
Compare
CHANGELOG: `hail.ggplot2.geom_point` now displays a legend group for a
column even when it has only one value in it.
Currently, if a column with only one value in it is passed to either the
`color` or the `shape` aesthetic for `geom_point`, the generated legend
will not include a group with a single entry for that aesthetic.
However, R's ggplot2 library in the same situation includes such a
legend group.
This change brings our ggplot implementation into line with R's ggplot2
in that regard.
For example, this code:
```python
import hail as hl
from hail.ggplot import ggplot, aes, geom_point
ht = hl.utils.range_table(10)
ht = ht.annotate(squared=ht.idx ** 2)
ht = ht.annotate(even=hl.if_else(ht.idx % 2 == 0, "yes", "no"))
ht = ht.annotate(threeven="good")
fig = (
ggplot(ht, aes(x=ht.idx, y=ht.squared))
+ geom_point(aes(color=ht.even, shape=ht.threeven))
)
fig.show()
```
generates a plot legend like this on `main`:
<legend>
but generates one like this on this branch:
<legend>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CHANGELOG:
hail.ggplot.geom_pointnow displays a legend group for a column even when it has only one value in it.Currently, if a column with only one value in it is passed to either the
coloror theshapeaesthetic forgeom_point, the generated legend will not include a group with a single entry for that aesthetic. However, R's ggplot2 library in the same situation includes such a legend group.This change brings our ggplot implementation into line with R's ggplot2 in that regard.
For example, this code:
generates a plot legend like this on
main:but generates one like this on this branch: