[ggplot] add shape aesthetic support to point geom#12207
[ggplot] add shape aesthetic support to point geom#12207danking merged 9 commits intohail-is:mainfrom
Conversation
|
|
||
| class ScaleShapeAuto(ScaleDiscrete): | ||
| def get_values(self, categories): | ||
| return [ |
There was a problem hiding this comment.
These are hardcoded here because there aren't equivalent methods to plotly.express.colors.(get|sample)_colorscale for the predefined list of shapes that plotly supports, and I couldn't find somewhere in the plotly API from which to directly import that list of constants.
patrick-schultz
left a comment
There was a problem hiding this comment.
Nice work! Thanks for taking this on!
I tried making a plot with only shape, not color. It should behave the same as color (in the discrete case), only using shapes instead of colors, but right now the legend uses "trace 0" etc. instead of the data values.
I was able to get the category names showing properly in the legend with just shapes by adding a 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=hl.if_else(ht.idx % 3 == 0, "good", "bad"))
fig = (
ggplot(ht)
+ aes(x=ht.idx, y=ht.squared, color=ht.even, shape=ht.threeven)
+ geom_point()
)
fig.show()I'm having trouble tracking down why this is happening, so I'll ask for some help with that tomorrow. |

Currently,
geom_pointdoes not support specifying a point shape via an aesthetic. This change adds support for ashapeaesthetic togeom_point. For example, using the following set of commands after this change has been applied produces the graph below. See the plotly documentation for a list of supported point shapes.