Skip to content
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

Strip plot does not actually render data points by default #548

Open
alexpeters1208 opened this issue Jun 13, 2024 · 8 comments
Open

Strip plot does not actually render data points by default #548

alexpeters1208 opened this issue Jun 13, 2024 · 8 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@alexpeters1208
Copy link
Contributor

Create a strip plot with dx.strip:

import plotly.express as px
from deephaven.pandas import to_table

tips = to_table(px.data.tips())

bill_distr = dx.strip(tips, x="total_bill", by="day")

The frame of the plot and axis labels will render, but the points themselves do not show up:
Screenshot 2024-06-13 at 10 10 58 AM

If you include a color explicitly:

bill_distr = dx.strip(tips, x="total_bill", by="day", color_discrete_sequence=["red"])

The plot will show up correctly:
Screenshot 2024-06-13 at 10 11 13 AM

@alexpeters1208 alexpeters1208 added bug Something isn't working triage labels Jun 13, 2024
@vbabich vbabich added this to the June 2024 milestone Jun 18, 2024
@vbabich vbabich removed the triage label Jun 18, 2024
@vbabich vbabich modified the milestones: June 2024, July 2024 Jul 9, 2024
@chipkent
Copy link
Member

See #554 (comment)

@mofojed mofojed modified the milestones: July 2024, September 2024 Sep 3, 2024
@jnumainville
Copy link
Collaborator

This appears to be a theming edge case

Essentially, a strip plot is a box plot with the box hidden and all points showing.
The edge case arises because of how that box is hidden

import deephaven.plot.express as dx

stocks = dx.data.stocks()

fig_strip = dx.strip(
    stocks, 
    x="Price",
    by="Sym"
)

This is the same case as Alex originally posted, it's just empty
Note that these traces have 'line': {'color': 'rgba(255,255,255,0)'}
Setting that alpha to 0 is what makes the box transparent of course
Now see this example

def testb(f):
    f.update_traces(line={'color': 'blue'}, boxpoints="all")
    
fig_strip_blue = dx.strip(
    stocks, 
    x="Price",
    by="Sym",
    unsafe_update_figure=testb
)

Image
As you can see, the points themselves are inheriting the color from line

This can of course be overriden, I'll just do it through unsafe_update_figure

def testrb(f):
    f.update_traces(line={'color': 'blue'}, boxpoints="all", marker={'color':'red'})
    
fig_strip_red_blue = dx.strip(
    stocks, 
    x="Price",
    by="Sym",
    unsafe_update_figure=testrb
)

Image

But, the problem is, we strip the marker color (as we should) but since we use the colorway for the theme, the marker inherits the transparent line color
I can remove the line color and this is themed "properly", but then the line is there when we don't want it.

def testl(f):
    f.update_traces(line=None, boxpoints="all")
    
fig_strip_themed = dx.strip(
    stocks, 
    x="Price",
    by="Sym",
    unsafe_update_figure=testl
)

Image

@bmingles @mattrunyon what do you think would be the best solution for this?

@bmingles
Copy link
Contributor

@jnumainville Why does line=None still show the lines?

@jnumainville
Copy link
Collaborator

Because the way they are hidden is through setting the line color to be completely transparent in the trace
'line': {'color': 'rgba(255,255,255,0)'}
Setting line=None doesn't get rid of the lines, just the color

@bmingles
Copy link
Contributor

@jnumainville How about setting line width to 0.

f.update_traces(line={'color':None,'width': 0}, boxpoints="all")

@jnumainville
Copy link
Collaborator

jnumainville commented Sep 16, 2024

That almost works, but the legend doesn't show up correctly. I'm guessing plotly doesn't handle a width of 0 in the legend.
This happens in plotly and px too. Might be worth opening a ticket.

import plotly.express as px

df = px.data.tips()

fig = px.strip(df, x="total_bill", y="day", color="time")
new_fig = fig.update_traces(line={"color": None, "width": 0})
new_fig.show()
Screenshot 2024-09-16 at 12 14 22 PM

@jnumainville
Copy link
Collaborator

I opened plotly/plotly.js#7159

@mofojed
Copy link
Member

mofojed commented Sep 30, 2024

PR opened against plotly for this: plotly/plotly.js#7162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants