altair

Filtering an aggregated chart with another aggregation field

 ̄綄美尐妖づ 提交于 2020-03-03 09:45:27
问题 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":

Drawing line plot for a histogram

喜你入骨 提交于 2020-03-01 03:46:11
问题 I'm trying to reproduce this chart using Altair as much as I can. https://fivethirtyeight.com/wp-content/uploads/2014/04/hickey-bechdel-11.png?w=575 I'm stuck at getting the black line dividing pass/fail. This is similar to this Altair example: https://altair-viz.github.io/gallery/step_chart.html. However: in the 538 viz the value for the final date must be extended for the full width of that last element. In the step chart example and my solution, the line stops as soon as the last date

How to add layers to a faceted chart in Altair?

混江龙づ霸主 提交于 2020-02-24 17:02:10
问题 Altair is a lovely visualization lib, with nice intuitive visual grammar API. I am however struggling adding a layer with rule marks to a faceted chart. Imagine you have a simple dataset: print(df[['Year', 'Profile', 'Saison', 'Pos']].to_csv()) ,Year,Profile,Saison,Pos 0,2017,6.0,Sommer,VL 1,2017,6.0,Winter,VL 13,2017,6.0,Winter,HL 12,2017,6.0,Sommer,HL 18,2017,6.0,Sommer,HR 6,2017,6.0,Sommer,VR 7,2017,6.0,Winter,VR 19,2017,6.0,Winter,HR 14,2018,5.5,Winter,HL 8,2018,5.5,Winter,VR 15,2018,5.5

How to add a slider to a choropleth in altair?

微笑、不失礼 提交于 2020-01-05 04:29:08
问题 I am trying to add a slider to my choropleth plot. The slider is based on "years" from 2006 to 2012 My data is like this: It can be downloaded from here: sample_data.csv When I plot the county level choropleth, It is doing an inner join w.r.t fips code for county using transform_lookup This is my code: slider = alt.binding_range(min=2006, max=2012, step=1) select_year = alt.selection_single(name="year", fields=['year'], bind=slider, init={'year': 2006}) alt.Chart(us_counties).mark_geoshape(

Altair remove border in LayerChart

感情迁移 提交于 2019-12-24 23:06:04
问题 I am trying to remove the border from an altair chart. This answer works perfectly but it fails when I try to visualize a layered chart. In my setting I have two charts, one for the contour m1 and one with the coordinates assigned to each category and properly colored m2 . I can add the setting configure_view(strokeWidth=0) to each and I can plot them independently, however when trying to plot m1+m2 I get an error. Objects with "config" attribute cannot be used within LayerChart. Consider

Remove border around vegaEmbed geoshape generated by altair?

允我心安 提交于 2019-12-24 03:59:31
问题 In the below image, observe the border around a map generated from Chart.save() to either HTML or JSON canvas (the border is inside the canvas, not CSS styled). For any other type of mark, one would expect to be able to use Chart.configure_view() to set strokeWidth=0 to remove the border, but this does not appear to affect this geoshape chart. The vegaEmbed embed options do not appear to document what creates this border. Is it possible to style or remove the border? 回答1: The way to remove

Altair interactive line plot, make line pop and highlighted when clicking icon on the right

不羁岁月 提交于 2019-12-24 01:49:13
问题 I had been trying to make with some interactive plot using Altair on jupyter lab. I had reached this stage where the results is below. As you can see, the line doesnt pop to the front when its highlighted. How do I make it pop to the front? Attached is the code. import altair as alt source = df selection = alt.selection_multi(fields=['class'], on='click') color = alt.condition(selection, alt.Color('class:O', legend=None, scale=alt.Scale(scheme='category10')), alt.value('lightgray')) base =

Adding spacing in heatmaps of python altair plots

允我心安 提交于 2019-12-13 15:17:11
问题 Is it possible to add some spacing in the heatmaps created by using mark_rect() in Altair python plots? The heatmap in figure 1 will be converted to the one in figure 2. You can assume that this is from a dataframe and each column corresponds to a variable. I deliberately drew the white bars like this to avoid any hardcoded indexed solution. Basically, I am looking for a solution where I can provide the column name and/or the index name to get white spacings drawn both vertically and/or

Bumbling around plotting two sets of seasonal data on the same chart

别来无恙 提交于 2019-12-13 03:58:36
问题 I have series of monthly inventory data since 2017. I have a series of inventory_forecasts since Dec2018 I am trying to plot the inventory data on a monthly-seasonal basis, and then overlay the inventory_forecasts of Jan2019 through Dec2019. The dataframe looks like: The first way I tried to make the chart does show all the data I want, but I'm unable to control the color of the inventory_zj line. Its color seems to be dominated by the color=year(date):N of the alt.Chart I configured. It is

Produce “dodged” or “side-by-side” bar/column charts in Altair?

删除回忆录丶 提交于 2019-12-11 10:57:45
问题 Apologies if this has been asked before, but I'm looking for a way to create bar-charts that are "dodged" (language from ggplot2 ) using the Altair library in python. I know Altair has this example: import altair as alt from vega_datasets import data source = data.barley() alt.Chart(source).mark_bar().encode( x='year:O', y='sum(yield):Q', color='year:N', column='site:N' ) That produces this plot: However, this has a lot of redundant labels and information. Ideally I want a plot where the