MCPcopy Index your code
hub / github.com/plotly/plotly.py / test_facets

Function test_facets

tests/test_optional/test_px/test_facets.py:7–46  ·  view source on GitHub ↗
(backend)

Source from the content-addressed store, hash-verified

5
6
7def test_facets(backend):
8 df = px.data.tips(return_type=backend)
9
10 fig = px.scatter(df, x="total_bill", y="tip")
11 assert "xaxis2" not in fig.layout
12 assert "yaxis2" not in fig.layout
13 assert fig.layout.xaxis.domain == (0.0, 1.0)
14 assert fig.layout.yaxis.domain == (0.0, 1.0)
15
16 fig = px.scatter(df, x="total_bill", y="tip", facet_row="sex", facet_col="smoker")
17 assert fig.layout.xaxis4.domain[0] - fig.layout.xaxis.domain[1] == approx(0.02)
18 assert fig.layout.yaxis4.domain[0] - fig.layout.yaxis.domain[1] == approx(0.03)
19
20 fig = px.scatter(df, x="total_bill", y="tip", facet_col="day", facet_col_wrap=2)
21 assert fig.layout.xaxis4.domain[0] - fig.layout.xaxis.domain[1] == approx(0.02)
22 assert fig.layout.yaxis4.domain[0] - fig.layout.yaxis.domain[1] == approx(0.07)
23
24 fig = px.scatter(
25 df,
26 x="total_bill",
27 y="tip",
28 facet_row="sex",
29 facet_col="smoker",
30 facet_col_spacing=0.09,
31 facet_row_spacing=0.08,
32 )
33 assert fig.layout.xaxis4.domain[0] - fig.layout.xaxis.domain[1] == approx(0.09)
34 assert fig.layout.yaxis4.domain[0] - fig.layout.yaxis.domain[1] == approx(0.08)
35
36 fig = px.scatter(
37 df,
38 x="total_bill",
39 y="tip",
40 facet_col="day",
41 facet_col_wrap=2,
42 facet_col_spacing=0.09,
43 facet_row_spacing=0.08,
44 )
45 assert fig.layout.xaxis4.domain[0] - fig.layout.xaxis.domain[1] == approx(0.09)
46 assert fig.layout.yaxis4.domain[0] - fig.layout.yaxis.domain[1] == approx(0.08)
47
48
49def test_facets_with_marginals(backend):

Callers

nothing calls this directly

Calls 1

scatterMethod · 0.80

Tested by

no test coverage detected