altair

How to highlight a bar by datetime value with Altair

橙三吉。 提交于 2020-06-16 17:10:30
问题 Similar to : https://altair-viz.github.io/gallery/bar_chart_with_highlighted_bar.html, is it possible to highlight a bar based on a specific date time value? I can't quite seem to make it work. import pandas as pd import altair as alt import datetime df = pd.DataFrame( { "year": [2019, 2019, 2019], "month": [1, 3, 7], "day": [1, 1, 1], "value": [5, 7, 9], } ) df["Mth"] = pd.to_datetime(dict(year=df["year"], month=df["month"], day=df["day"])) df.drop( ["year", "month", "day"], axis=1, inplace

How to highlight a bar by datetime value with Altair

佐手、 提交于 2020-06-16 17:09:57
问题 Similar to : https://altair-viz.github.io/gallery/bar_chart_with_highlighted_bar.html, is it possible to highlight a bar based on a specific date time value? I can't quite seem to make it work. import pandas as pd import altair as alt import datetime df = pd.DataFrame( { "year": [2019, 2019, 2019], "month": [1, 3, 7], "day": [1, 1, 1], "value": [5, 7, 9], } ) df["Mth"] = pd.to_datetime(dict(year=df["year"], month=df["month"], day=df["day"])) df.drop( ["year", "month", "day"], axis=1, inplace

multiple column/row facet wrap in altair

孤者浪人 提交于 2020-06-09 16:49:06
问题 In ggplot2 , it's easy to create a faceted plot with facets that span both rows and columns. Is there a "slick" way to do this in altair ? facet documentation It's possible to have facets plot in a single column, import altair as alt from vega_datasets import data iris = data.iris chart = alt.Chart(iris).mark_point().encode( x='petalLength:Q', y='petalWidth:Q', color='species:N' ).properties( width=180, height=180 ).facet( row='species:N' ) and in a single row, chart = alt.Chart(iris).mark

Altair color bar chart by value not presented

▼魔方 西西 提交于 2020-05-29 10:45:25
问题 Trying to color a bar chart using a condition based on a value that is not presented in the chart. I got this dataframe: I would like to color the bar green if row.presented_value > row.coloring_value , else color red. I saw examples of conditions by constant values and by displayed values, but couldn't make it work for me. In the code example below I would like both foo and bar to be red. import pandas as pd df = pd.DataFrame({'name':['bar','foo'], 'presented_value':[10,20], 'coloring_value'

Altair: Can't facet layered plots

社会主义新天地 提交于 2020-05-12 16:08:44
问题 I read in the documentation that I can facet a multi-layer plot, but somehow the data are lumped together in output plot, and repeated in all facets. I can facet each layer with no problem, here is an example with the cars dataset: import altair as alt from altair import datum from vega_datasets import data cars = data.cars() horse = alt.Chart(cars).mark_point().encode( x = 'Weight_in_lbs', y = 'Horsepower' ) chart = alt.hconcat() for origin in cars.Origin.unique(): chart |= horse.transform

Altair: Can't facet layered plots

孤人 提交于 2020-05-12 16:08:10
问题 I read in the documentation that I can facet a multi-layer plot, but somehow the data are lumped together in output plot, and repeated in all facets. I can facet each layer with no problem, here is an example with the cars dataset: import altair as alt from altair import datum from vega_datasets import data cars = data.cars() horse = alt.Chart(cars).mark_point().encode( x = 'Weight_in_lbs', y = 'Horsepower' ) chart = alt.hconcat() for origin in cars.Origin.unique(): chart |= horse.transform

Getting Altair to work with Jupyter Notebook

戏子无情 提交于 2020-04-10 04:22:08
问题 Trying to get Altair to work with Jupyter Notebook, I installed it using conda install -c conda-forge altair vega_datasets notebook vega But when I try to do an example plot import altair as alt from vega_datasets import data # for the notebook only (not for JupyterLab) run this command once per session alt.renderers.enable('notebook') iris = data.iris() alt.Chart(iris).mark_point().encode( x='petalLength', y='petalWidth', color='species' ) as seen in their quick start guide, I get ValueError

Altair automatic save chart using selenium chromedriver

杀马特。学长 韩版系。学妹 提交于 2020-03-23 08:50:13
问题 Asking this again as the previous has been closed without any useful solution. I am trying to produce few charts in a loop and save them automatically. I am working on Windows, using Chrome. I have been following the documentation on how to save a chart in svg. I downloaded the appropriate ChromeDriver for my Chrome version. gdf is my geodataframe and everything works smoothly and I can generate and manually save charts. Also, this example taken from the chromium documentation works: import

Altair automatic save chart as svg using selenium chromedriver [duplicate]

瘦欲@ 提交于 2020-03-04 21:33:32
问题 This question already has answers here : selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH error with Headless Chrome (1 answer) WebDriverException: Message: 'chromedriver' executable needs to be in PATH while setting UserAgent through Selenium Chromedriver Phyton (1 answer) Error Message: 'chromedriver' executable needs to be PATH (1 answer) Closed last month . I am trying to produce few charts in a loop and save them automatically. I am

Filtering an aggregated chart with another aggregation field

泪湿孤枕 提交于 2020-03-03 09:45:57
问题 I'm trying to produce something similar to the K-top example. Except that instead of filtering out and displaying the same aggregated field data, I want: to display one type of aggregated data (the max of daily temps) and filter on another aggregation field ( the mean of daily temps) I've created an observable notebook here to build my test case, and this is how far I got. { "$schema": "https://vega.github.io/schema/vega-lite/v4.json", "data": {"url": "data/seattle-weather.csv"}, "transform":