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.

Legend loses gradient if shared between layers

See original GitHub issue

The following:

{
  "layer": [{
    "mark": { "type": "line" },
    "encoding": {
      "color": {
        "type": "quantitative",
        "field": "c"
      }
    }
  }, {
    "mark": { "type": "circle" },
    "encoding": {
      "color": {
        "type": "quantitative",
        "field": "c"
      }
    }
  }],
  "data": {"values": [{"c": 1}, {"c": 2}]}
}

Currently produces:

visualization(50)

This is surprising - I would have expected a gradient legend.

If a layer is removed (which one is removed doesn’t matter), the output is correct:

visualization(52)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kanitwcommented, Apr 6, 2020

I don’t think this is expected behavior

I think we could fix this in a few ways:

  1. in Vega (when fill and stroke encodes the same color). or 2) encode “color” in legend parse and convert it to fill or stroke later in assemble.

That said, since there is a good workaround, I’ll make this issue P3.

1reaction
domoritzcommented, Apr 6, 2020

Okay, so the issue is that Vega uses a different legend when both fill and stroke are encoding a scale. That’s a bit surprising but also kinda makes sense since only a symbol can encode both gradient and fill.

Removing one or the other does not make sense in the general case so I think that the behavior is actually as expected.

If you want a gradient legend, you need to tell Vega-Lite with "legend": {"type": "gradient"}.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fill and Color Legend Disappear while Adding Layers
1 Answer 1 · The issue is I want the scales to be merged and share the same title. The issue is that...
Read more >
Creating a gradient-based legend - qgis - GIS Stack Exchange
To get the legend to say High or Low, you can achieve this by deleting everything inside the Legend Format textbox and then...
Read more >
Visualizing the vanishing gradient problem
Looking at the gradients of each layer; The Glorot initialization. Configuration of multilayer perceptron models. Because neural networks are ...
Read more >
Vanishing and Exploding Gradients in Neural Network Models
Moving on to the exploding gradients, in a nutshell, this problem is due to the initial weights assigned to the neural nets creating...
Read more >
Arrange a legend—ArcGIS Pro | Documentation
Reorder legend items by expanding the legend in the Contents pane to see the legend items. Drag items up or down in the...
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