Open alexpeters1208 opened 5 months ago
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
)
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
)
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
)
@bmingles @mattrunyon what do you think would be the best solution for this?
@jnumainville Why does line=None
still show the lines?
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
@jnumainville How about setting line width to 0.
f.update_traces(line={'color':None,'width': 0}, boxpoints="all")
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()
PR opened against plotly for this: https://github.com/plotly/plotly.js/pull/7162
Create a strip plot with
dx.strip
:The frame of the plot and axis labels will render, but the points themselves do not show up:
If you include a color explicitly:
The plot will show up correctly: