vega

Display vega spec in Jupyter Lab

别说谁变了你拦得住时间么 提交于 2021-02-11 12:50:28
问题 How can I display a vega spec (such as this force directed layout) in Jupyter Lab/JupyterLab? 回答1: You can use Vega Embed through the javascript extension: Add the scripts: %%javascript var script = document.createElement('script'); script.type = 'text/javascript'; script.src = '//cdn.jsdelivr.net/npm/vega@5'; document.head.appendChild(script); var script = document.createElement('script'); script.type = 'text/javascript'; script.src = '//cdn.jsdelivr.net/npm/vega-embed@6'; document.head

Dynamically Change Y-Axis Field in Encoding Based on Selection Vega-Lite

天涯浪子 提交于 2021-02-10 15:42:00
问题 How can I dynamically change a data field encoded for the y-axis based upon a selection? I am trying to build a visualization to display event count data over the 24 hours of a day, and I want the user to be able to select different timezones (e.g. EST, CST, MST, or PST). To do this, I have built out a single selection where I specify all the options I list above in the parentheses, with EST being set as my default. I want to create a condition where when I chose another option besides EST, I

Add legend to line & bars to Altair chart without using size/color

自作多情 提交于 2021-02-10 14:51:44
问题 I'm using Altair to create a chart with multiple lines each of which has multiple bands (representing different CI) & I'm struggling to understand how I can add a legend. For example, in this considerably simpler example: import altair as alt import pandas as pd df = pd.DataFrame(data={'col1': [1, 2,4,5,6], 'col2': [3, 4,7,4,4], 'col3': [1.5, 2.6,4.6,5.6,6.6], 'col4': [3.6, 4.6,7.6,4.6,4.4],'col5': [1.9, 2.9,4.9,5.9,6.9], 'col4': [3.9, 4.9,7.9,4.9,4.9]}) line = alt.Chart(df).mark_line(color=

How to show Vega visualizations in Google Colab

扶醉桌前 提交于 2021-02-10 05:33:08
问题 I can use Altair to show Vega-Lite visualizations in Google Colab. But is there a way to show plain Vega visualizations? I tried ipyvega in Google Colab. But when I run their example in Google Colab, then nothing shows up, and there is no error. 回答1: You can display a vega chart in Colab using the altair.vega.Vega class, once you have enabled the Colab renderer. Here is an example: from urllib import request import json with request.urlopen("https://vega.github.io/vega/examples/bar-chart.vg

Vega-Lite / Kibana difference to manage JSON object

此生再无相见时 提交于 2021-01-29 07:16:01
问题 I am trying to use Vega in Kibana and I have trouble manage data that are sub-object within the data. It is working fine with https://vega.github.io/editor/#/edited but when I do it with Kibana, it doesn't work. Vega-editor: Kibana: I have tried a lot of things to access the typology, I am stuck now. { "$schema": "https://vega.github.io/schema/vega-lite/v2.json", "title": "Test", "datasets": { "stores": [ { "storeId": "toto", "info": { "typology": "type1" } }, { "storeId": "tata", "info": {

Is it possible to display vega/vega-lite bar based on period time column?

雨燕双飞 提交于 2021-01-29 05:53:17
问题 I was wonder if it is possible to create a vega/vega-lite visualization , based on time periodic columns. For example , assume that i would like to display a graph of athletics results in a bar/other visualization. rio-2016-athletics I have tried to make some changes to simple bar chart bellow. I have edited only the "amount" column in order to display time-period results: "data": [ { "name": "table", "values": [ {"category": "1", "amount": 1:42.15}, {"category": "2", "amount": 1:42.61}, {

Is it possible to display vega/vega-lite bar based on period time column?

谁说我不能喝 提交于 2021-01-29 05:52:54
问题 I was wonder if it is possible to create a vega/vega-lite visualization , based on time periodic columns. For example , assume that i would like to display a graph of athletics results in a bar/other visualization. rio-2016-athletics I have tried to make some changes to simple bar chart bellow. I have edited only the "amount" column in order to display time-period results: "data": [ { "name": "table", "values": [ {"category": "1", "amount": 1:42.15}, {"category": "2", "amount": 1:42.61}, {

Can you have facets & layers in single Vegalite plot?

本小妞迷上赌 提交于 2021-01-28 07:32:35
问题 I am struggling to understand why a layer spec like the below: "layer": [ {"encoding": { "facet": {"field": "FEATURE_VALUE"}, "x": { "field": "DATE", "type": "temporal" }, "y": { "field": "VALUE", "type": "quantitative" } }, "mark": { "type": "line" }} ] Throws an error to the effect of: Cannot read property 'push' of undefined Meanwhile, the unit spec: "encoding": { "facet": {"field": "FEATURE_VALUE"}, "x": { "field": "DATE", "type": "temporal" }, "y": { "field": "VALUE", "type":

Can you have facets & layers in single Vegalite plot?

跟風遠走 提交于 2021-01-28 07:18:29
问题 I am struggling to understand why a layer spec like the below: "layer": [ {"encoding": { "facet": {"field": "FEATURE_VALUE"}, "x": { "field": "DATE", "type": "temporal" }, "y": { "field": "VALUE", "type": "quantitative" } }, "mark": { "type": "line" }} ] Throws an error to the effect of: Cannot read property 'push' of undefined Meanwhile, the unit spec: "encoding": { "facet": {"field": "FEATURE_VALUE"}, "x": { "field": "DATE", "type": "temporal" }, "y": { "field": "VALUE", "type":

Changing the domain of a scale without shifting the entire plot

家住魔仙堡 提交于 2021-01-28 07:05:45
问题 I am working on a realtime simulation. I generate an hour of data, but I only want to present a portion of that, and scroll the plot when I get close to the right edge. I define two signals: "signals": [ { "name": "timeStart", "init":0 }, { "name": "timeEnd", "init": 480000 } ], and a scale "scales": [ { "name": "x", "type": "time", "range": "width", "nice": "minute", "domainMin": {"signal": "timeStart"}, "domainMax": {"signal": "timeEnd"}, "zero": false } I have a filter in the marks to make