Skip to content

Commit 412a7f3

Browse files
add test for PX orthogonal ordering
1 parent 235cdce commit 412a7f3

File tree

1 file changed

+40
-0
lines changed
  • packages/python/plotly/plotly/tests/test_core/test_px

1 file changed

+40
-0
lines changed

packages/python/plotly/plotly/tests/test_core/test_px/test_px.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,43 @@ def test_px_templates():
182182
assert fig.layout.xaxis3.showgrid is None
183183
assert fig.layout.yaxis2.showgrid
184184
assert fig.layout.yaxis3.showgrid
185+
186+
187+
def test_orthogonal_orderings():
188+
from itertools import permutations
189+
190+
df = px.data.tips()
191+
192+
symbol_sequence = ["circle", "diamond", "square", "cross"]
193+
color_sequence = ["red", "blue"]
194+
195+
for days in permutations(df["day"].unique()):
196+
for times in permutations(df["time"].unique()):
197+
fig = px.scatter(
198+
df,
199+
x="total_bill",
200+
y="tip",
201+
facet_row="time",
202+
facet_col="day",
203+
color="time",
204+
symbol="day",
205+
symbol_sequence=symbol_sequence,
206+
color_discrete_sequence=color_sequence,
207+
category_orders=dict(day=days, time=times),
208+
)
209+
210+
for col in range(len(days)):
211+
for trace in fig.select_traces(col=col + 1):
212+
assert days[col] in trace.hovertemplate
213+
214+
for row in range(len(times)):
215+
for trace in fig.select_traces(row=2 - row):
216+
assert times[row] in trace.hovertemplate
217+
218+
for trace in fig.data:
219+
for i, day in enumerate(days):
220+
if day in trace.name:
221+
assert trace.marker.symbol == symbol_sequence[i]
222+
for i, time in enumerate(times):
223+
if time in trace.name:
224+
assert trace.marker.color == color_sequence[i]

0 commit comments

Comments
 (0)