8000 How facet resolves multiple records for the facetted parameter not documented · Issue #27 · altair-viz/altair-viz.github.io · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
How facet resolves multiple records for the facetted parameter not documented  #27
Open
@mcp292

Description

@mcp292

Please let me know if there is a forum specifically for Altair questions and help and I will move this there.

I haven't been able to find in the documentation how facet resolves multiple entries for the facetted parameter.

In the MWE below, what does facet() do when it encounters 3 entries where P = HD, and T = 0, yet only plots one value at HD, 0 in the t_facet (T) plot.

Is this just a flawed plot?

MWE

import pandas as pd
import altair as alt


data = [{"P": "HD", "T": 0,  "C":100, "Max": 1},
        {"P": "HD", "T": 0,  "C":400, "Max": 3},
        {"P": "HD", "T": 0,  "C":800, "Max": 0},
        {"P": "HD", "T": 23, "C":100, "Max": 2},
        {"P": "HD", "T": 23, "C":400, "Max": 1},
        {"P": "HD", "T": 23, "C":800, "Max": 1},
        {"P": "HD", "T": 80, "C":100, "Max": 7},
        {"P": "HD", "T": 80, "C":400, "Max": 2},
        {"P": "HD", "T": 80, "C":800, "Max": 1},
        {"P": "LD", "T": 0,  "C":100, "Max": 1},
        {"P": "LD", "T": 0,  "C":400, "Max": 2},
        {"P": "LD", "T": 0,  "C":800, "Max": 7},
        {"P": "LD", "T": 23, "C":100, "Max": 7},
        {"P": "LD", "T": 23, "C":400, "Max": 1},
        {"P": "LD", "T": 23, "C":800, "Max": 0},
        {"P": "LD", "T": 80, "C":100, "Max": 2},
        {"P": "LD", "T": 80, "C":400, "Max": 0},
        {"P": "LD", "T": 80, "C":800, "Max": 1}]

df = pd.DataFrame(data)

chart = alt.Chart(df).mark_bar().encode(x="P:N", y="Max:Q", color="P:N")

t_facet = chart.facet("T:N")
c_facet = chart.facet("C:N")
     P   T    C  Max
0   HD   0  100    1
1   HD   0  400    3
2   HD   0  800    0
3   HD  23  100    2
4   HD  23  400    1
5   HD  23  800    1
6   HD  80  100    7
7   HD  80  400    2
8   HD  80  800    1
9   LD   0  100    1
10  LD   0  400    2
11  LD   0  800    7
12  LD  23  100    7
13  LD  23  400    1
14  LD  23  800    0
15  LD  80  100    2
16  LD  80  400    0
17  LD  80  800    1

t_facet
c_facet

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0