Giter Club home page Giter Club logo

altair-viz.github.io's People

Contributors

binste avatar eocarragain avatar jakevdp avatar joelostblom avatar mattijn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

altair-viz.github.io's Issues

Using one label for a facet grid not documented

Using one label for an entire facet grid is not documented in Adjusting Axis Labels.

How can I make this plot only use one y-label?

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=alt.Y("Max:Q", title="Maximum Long Word Observed (units)"),
    color="P:N",
    row="T:N",
    column="C:N"
).properties(width=100, height=100)
     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

facet_grid

properties() method not documented

I'm reading through Encodings and noticed the awesome properties() method.

Where do I find documentation on this?

I would have expected first mention of it to be hyperlinked. It does not come up in searches on the docs page

How facet resolves multiple records for the facetted parameter not documented

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

Layered Histogram example does not take into account null values

Issue

This is based on the issue #2411 that I originally posted in the altair repo.

The method for making layered histograms suggested on altair-viz.github.io seems to fail to take into account null values within the range of the data: bins that should be empty are represented as having 1 observation.


Examples

Altair:

import pandas as pd
import altair as alt
import numpy as np

np.random.seed(42)

# Generating Data
source = pd.DataFrame({
    'Trial A': np.random.normal(0, 0.8, 1000),
    'Trial B': np.random.normal(-2, 1, 1000),
    'Trial C': np.random.normal(3, 2, 1000)
})

alt.Chart(source).transform_fold(
    ['Trial A', 'Trial B', 'Trial C'],
    as_=['Experiment', 'Measurement']
).mark_area(
    opacity=0.3,
    interpolate='step'
).encode(
    alt.X('Measurement:Q', bin=alt.Bin(maxbins=100)),
    alt.Y('count()', stack=None),
    alt.Color('Experiment:N')
)

layered_histogram_altair


Solution

The suggested method should be mark_bar instead of mark_area, which correctly represents the data. I'll be doing a PR shortly.

layered_histogram_altair_solution

The underlying issue with mark_area still needs fixing however: here's how it looks in Seaborn:

layered_histogram_seaborn

Should I open the issue in https://github.com/vega/vega-lite?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.