vega-lite

Is it possible to add a background image to a plot in vega or vega-lite?

与世无争的帅哥 提交于 2019-12-11 08:40:20
问题 I see from https://vega.github.io/vega-lite/docs/config.html that it is possible to change the background color. But i don't see any docs for adding an underlay background image. 回答1: vega-lite creates a canvas element. So adding a background image is explained in a question about how to add a background to a canvas element. HTML5 Canvas background image But you can just do it with css: canvas { background: url("my_background.png"); } This is just like any other background image css. https:/

Disconnect points to plot overlay in Vega-lite / Vega

徘徊边缘 提交于 2019-12-11 08:33:31
问题 An example in vega-editor here I don’t want dateTime 5 & dateTime 7 to be connected since they are not consecutive. Idea is to plot on overlay based on some condition and connect only when the count is >=5. Has anyone tried this already? 回答1: You can replace your filter statement: {"filter": "datum.count >= 5"} With a calculate statement that sets filtered values to null: {"as": "count", "calculate": "if(datum.count >= 5, datum.count, null)"} The result is here 来源: https://stackoverflow.com

Altair/Vega-Lite bar chart: filter top K bars from aggregated field

删除回忆录丶 提交于 2019-12-10 11:34:51
问题 I'm visualizing a dataset that has, for instance, a categorical field. I want to create a bar chart that shows the different categories for that field with their cardinality, sorted in 'ascendind'/'descending' order. This can simply be achieved with altair : import pandas as pd import altair as alt data = {0:{'Name':'Mary', 'Sport':'Tennis'}, 1:{'Name':'Cal', 'Sport':'Tennis'}, 2:{'Name':'John', 'Sport':'Tennis'}, 3:{'Name':'Jane', 'Sport':'Tennis'}, 4:{'Name':'Bob', 'Sport':'Golf'}, 5:{'Name

Can we add event listeners to “Vega-Lite” specification?

我与影子孤独终老i 提交于 2019-12-06 00:56:29
I am new to Vega and Vega-Lite. I am creating a simple bar chart using Vega-Lite but I am not able to add any event listeners e.g. "hover". I want to hover a bar and change the color of the bar. If you're using Vega-Embed , it returns a promise with a reference to the view which allows you to use addEventListener - explained in the docs here . Here is an example: const width = 600 const color = blue embed(element, { $schema: 'https://vega.github.io/schema/vega-lite/3.0.0-rc6.json', data: { 'values': data }, mark: { type: 'line', color, point: { color, } }, width, height: width / 2, encoding: {

How to plot several variables on an axis with Vega-Lite?

空扰寡人 提交于 2019-12-04 05:19:46
问题 Following Vega-Lite's Seattle weather tutorial, it was easy to plot avg min temperature by month: { "$schema": "https://vega.github.io/schema/vega-lite/v2.json", "data": { "url": "https://vega.github.io/vega-lite/data/seattle-weather.csv" }, "mark": "line", "encoding": { "x": { "timeUnit": "month", "field": "date", "type": "temporal" }, "y": { "aggregate": "mean", "field": "temp_min", "type": "quantitative" } } } This dataset also has temp_max variable. How can I plot both temp_min and temp

How to plot several variables on an axis with Vega-Lite?

核能气质少年 提交于 2019-12-02 04:10:43
Following Vega-Lite's Seattle weather tutorial, it was easy to plot avg min temperature by month: { "$schema": "https://vega.github.io/schema/vega-lite/v2.json", "data": { "url": "https://vega.github.io/vega-lite/data/seattle-weather.csv" }, "mark": "line", "encoding": { "x": { "timeUnit": "month", "field": "date", "type": "temporal" }, "y": { "aggregate": "mean", "field": "temp_min", "type": "quantitative" } } } This dataset also has temp_max variable. How can I plot both temp_min and temp_max on y-axis? You can use layering as described at https://vega.github.io/vega-lite/docs/layer.html . {

How do I add a secondary Y axis to my vega-lite chart?

北战南征 提交于 2019-12-01 03:53:16
问题 This question shows a way to add multiple time series to a vega-lite chart: How to plot several variables on an axis with Vega-Lite? Is there a way to put the second series on the secondary Y axis? I'm talking about putting another Y axis on the right hand side so that the time series can have different scales but still be compared. The following image demonstrates the kind of chart that I'm after: Here is an example chart, please show me how to move the second time series to a new Y axis on