-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ggplot] add shape aesthetic support to point geom #12207
Conversation
|
||
class ScaleShapeAuto(ScaleDiscrete): | ||
def get_values(self, categories): | ||
return [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_point
does not support specifying a point shape via an aesthetic. This change adds support for ashape
aesthetic 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.