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.

setting color scheme in using vegalite

See original GitHub issue

Hi Guys,

Any idea why the following snippet shows the correct color scheme in a vega-lite editor, but when passing the snippet into folium.features.VegaLite, only the green color scheme is used?

screenshots below

{
  "data": {
    "values": [
      {"value": 38,"variables": "median income"},
      {"value": 43,"variables": "education"},
      {"value": 16,"variables": "lone parent"},
      {"value": 27,"variables": "unemployment rate"},
      {
        "value": 6,
        "variables": "non speaking (eng or french)"
      }
    ]
  },
  "description": "A simple bar chart with embedded data",
  "encoding": {
    "color": {
      "field": "value",
      "scale": {"domain": [1,55],"scheme": "yelloworangered"},
      "type": "quantitative"
    },
    "x": {"field": "variables","type": "nominal"},
    "y": {
      "field": "value",
      "type": "quantitative",
      "scale": {"domain": [0,55]}
    }
  },
  "mark": "bar"
}

In a vega-lite editor:

vg

In folium,

vega = folium.features.VegaLite(snippet)
marker=folium.RegularPolygonMarker(ll)
popup = folium.Popup()
vega.add_to(popup)
popup.add_to(marker)
marker.add_to(m)
m

shows this: fo

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
Alcampopianocommented, Nov 27, 2017

@Conengmo Thanks Frank. You are correct. Setting the colour scheme works perfectly if I’m using Vega Lite 1 vernacular. For those who need it, here is an example:

{
  "config": {
    "mark": {"filled": true,"orient": "vertical","opacity": ".5"},
    "axis": {
      "properties": {
        "title": {
          "font": {"value": "Helvetica"},
          "fontSize": {"value": 50}
        },
        "labels": {
          "font": {"value": "Helvetica"},
          "fontSize": {"value": 10}
        }
      }
    }
  },
  "description": "A simple bar chart with embedded data.",
  "data": {
    "values": [
      {"a": "A","b": 28},
      {"a": "B","b": 55},
      {"a": "C","b": 43},
      {"a": "D","b": 91},
      {"a": "E","b": 81},
      {"a": "F","b": 53},
      {"a": "G","b": 19},
      {"a": "H","b": 87},
      {"a": "I","b": 52}
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {
      "field": "a",
      "type": "nominal",
      "fontsize": 40,
      "axis": {"labelAngle": 45}
      
    },
    "y": {"field": "b","type": "quantitative"},
    "color": {
      "field": "b",
      "type": "quantitative",
      "legend": null,
      "scale": {"domain": [0,100],"range": ["yellow","red"]}
    }
  }
}
0reactions
ocefpafcommented, Nov 25, 2017

This is a vegalite question and not folium. I am closing it b/c it is not actionable by our devs. Feel free to continue the discussion here though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Color Schemes | Vega
Color schemes provide a set of named color palettes for both discrete and continuous color encodings. Vega provides a collection of perceptually-motivated color ......
Read more >
How to color lines with specific colors in Vega-Lite?
You can set a custom Color Scheme using the scale.domain and scale.range arguments: "color": { "field": "symbol", "type": "nominal", ...
Read more >
Vega Colour Schemes / Simon Lang - Observable
These schemes include both continuous color palettes, and a limited set of discrete palettes with a suffix that indicates the desired number of...
Read more >
Tutorial · VegaLite.jl - Queryverse
What if we don't want to use a color scheme that signals any order? In that case we can change the type of...
Read more >
Heatmaps with Vega-Lite – Codelibrary - Opendatasoft
Encoding block is the most important, it contains your axis settings, color and size settings, and the legend · quantitative : numerical values...
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