code: def test_facets_with_marginals():
      df = px.data.tips()
  
      fig = px.histogram(
          df, x="total_bill", facet_col="sex", marginal="rug"
      )
      assert len(fig.data) == 4
      fig = px.histogram(
          df, x="total_bill", facet_row="sex", marginal="rug"
      )
      assert len(fig.data) == 2
  
      fig = px.histogram(
          df, y="total_bill", facet_col="sex", marginal="rug"
      )
      assert len(fig.data) == 2
      fig = px.histogram(
          df, y="total_bill", facet_row="sex", marginal="rug"
      )
      assert len(fig.data) == 4
  
      fig = px.scatter(
          df, x="total_bill", y="tip", facet_col="sex", marginal_x="rug"
      )
      assert len(fig.data) == 4
      fig = px.scatter(
          df,
          x="total_bill",
          y="tip",
          facet_col="day",
          facet_col_wrap=2,
          marginal_x="rug",
      )
      assert len(fig.data) == 8  # ignore the wrap when marginal is used
      fig = px.scatter(
          df, x="total_bill", y="tip", facet_col="sex", marginal_y="rug"
      )
      assert (
          len(fig.data) == 2
      )  # ignore the marginal in the facet direction
  
      fig = px.scatter(
          df, x="total_bill", y="tip", facet_row="sex", marginal_x="rug"
      )
      assert (
          len(fig.data) == 2
      )  # ignore the marginal in the facet direction
      fig = px.scatter(
          df, x="total_bill", y="tip", facet_row="sex", marginal_y="rug"
      )
      assert len(fig.data) == 4
  
      fig = px.scatter(
          df,
          x="total_bill",
          y="tip",
          facet_row="sex",
          marginal_y="rug",
          marginal_x="rug",
      )
      assert (
          len(fig.data) == 4
      )  # ignore the marginal in the facet direction
      fig = px.scatter(
          df,
          x="total_bill",
          y="tip",
          facet_col="sex",
          marginal_y="rug",
          marginal_x="rug",
      )
      assert (
          len(fig.data) == 4
      )  # ignore the marginal in the facet direction
      fig = px.scatter(
          df,
          x="total_bill",
          y="tip",
          facet_row="sex",
          facet_col="sex",
          marginal_y="rug",
          marginal_x="rug",
      )
      assert len(fig.data) == 2
  
file_path: plotly.py/packages/python/plotly/plotly/tests/test_optional/test_px/test_facets.py
imports: import pandas
  import plotly.express
  from pytest import approx
  import pytest
  import random
label_desc: Use image node_id 2 for calling a global function with example usage: test_facets_with_marginals() without return types