question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stacking with size channel

See original GitHub issue

I am not sure whether this is a bug report or a feature request, but I’ll show the logic here. I wrote the code with Altair but will try to share the links to the vega-lite editor as well.

So I first generate a list of temporal events, and shared the resulting json on gist.

I am trying to get a stacked view of different types of events, first the more natural view with stacked bars, (link):

base = (
    alt.Chart(
        alt.Data(
            url="https://gist.githubusercontent.com/xoolive/7cbc548c90bf9eb998e35a20c1971a69/raw/0dde22efc14263bf7dc0662d2d4743e6fa583898/example.json"
        )
    )
    .transform_aggregate(total="count(category)", groupby=["hour", "category"])
    .encode(
        alt.X("utchours(hour):T", title="hour (UTC)"),
        alt.Color(
            "category:N",
            scale=alt.Scale(
                domain=["good", "bad", "very bad", "unknown"],
                range=["#4e79a7", "#f28e2b", "#e15759", "#bab0ac"],
            ),
        ),
    )
)

calendar = (
    base.encode(
        alt.Row("utcmonthdate(hour):T", title=""),
        alt.Y("total:Q"),
    )
    .mark_bar()
    .properties(height=100)
)
calendar

The output is correctly stacked: image

Now since my list of days is much longer, I want to encode things a bit differently, with “bubbles” of different size. So the y channel would become the size channel (link):

calendar = (
    base.transform_filter("datum.category != 'unknown'")
    .encode(
        alt.Y("utcmonthdate(hour):O", title=None),
        alt.Size("total:Q"),
    )
    .mark_circle()
    .configure_legend(orient="bottom")
)
calendar

image

This could look correct, but actually, it appears that the sizes are not stacked and that some bubbles may come in front of others. I wrote the following workaround, generating stacks manually, playing with the order channel, and with a stack ordering consistent with my wishes (is it related to https://github.com/vega/vega-lite/issues/1734 ?) but in the end I am not sure whether the process could be facilitate so as to get the following output ⬇️ (with (link)) for the previous code snippet ⬆️

cheating_sorts = pd.DataFrame(
    dict(category=["unknown", "good", "bad", "very bad"], value=[3, 2, 1, 0])
)
calendar = (
    base.transform_lookup(
        lookup="category",
        from_=alt.LookupData(data=cheating_sorts, key="category", fields=["value"]),
    )
    .transform_stack(
        stack="total",
        as_=["size", "size2"],
        groupby=["hour"],
        sort=[alt.SortField("value")],
    )
    .transform_filter("datum.category != 'unknown'")
    .encode(
        alt.Y("utcmonthdate(hour):O", title=None),
        alt.Size("size2:Q", title="total"),
        alt.Order("category:N"),
    )
    .mark_circle()
    .configure_legend(orient="bottom")
)
calendar

image

Thank you for the support!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
domoritzcommented, Apr 14, 2021

Great idea. I think we should apply stacking to sized circles as well.

Here is the simplest example I could come up with.

Open the Chart in the Vega Editor

Screen Shot 2021-04-14 at 12 28 40

Would you want to take a stab at a pull request?

0reactions
kanitwcommented, Aug 15, 2021

I could see an argument for a warning, but this should be rare enough so I don’t plan to fix this.

If you strongly feel like a warning, feel free to submit a PR. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stacking multidimensional numpy arrays with one different ...
@Divakar In the dimensions of my network - i can assign "none" and it will allow for ambiguous length. Is there anything similar...
Read more >
Is it possible to have different channel dimensions in a CNN?
Let's say I have two channels that I wish to feed into a CNN. One of the channel contains 4 traces and has...
Read more >
Size and Shape Manipulation of Channel Structures ...
Size and Shape Manipulation of Channel Structures Assembled Via Saddle stacking of Tetrapodal Adamantanes Containing Aryl Butadiynyl Moieties.
Read more >
Channel stacking switch technology for residential DBS ...
With channel stacking, multiple channels are transmitted on a single cable based on the demands from multiple STBs and tuners connected to ...
Read more >
Quick questions about multi channel/session stacking (I hope)
Hi, I'm assuming that, if I do a multi-channel, multi-session stack of Ha and RGB: The correct algorithms are assigned to each channel...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found