Questions tagged [altair]
Altair is a declarative statistical visualization library for Python, based on Vega-Lite. It provides a high-level API for creating complex visualizations with minimal code. Please include code and sample data in your question.
altair
1,375
questions
0
votes
0
answers
13
views
How to control width of .hconcat subplot
I am trying to concatenate two graphs, with the one on the beign dependent on the selection made on the graph on the left. The problem is that the right graph is a bar type, and depending on the ...
2
votes
1
answer
34
views
altair: how to make an interactive plot with a regression line on top of it?
I'm trying to make an interactive plot that has a regression line on top of it. Here is the plot in the Vega editor and here is a gist of the Altair source (MRE). This is heavily influenced by this ...
0
votes
0
answers
17
views
log-log regression, possible in Altair?
Is there any way to do a log-log regression (both x and y axes are on a logarithmic scale)? Linear-linear, linear-log, log-linear all seem straightforward.
0
votes
1
answer
62
views
Using a list of colors for a bar chart in Altair
I am trying to provide a list of colors to bind to the bar marks in Altair, similar to how matplotlib's pyplot.bar(color=list_of_colors) can specify the color for each individual bar, like in the ...
3
votes
1
answer
56
views
Altair Barchart is blank, matplotlib equivalent shows correct visualization
I have been using altair for a time and this is the first time that I have experienced this issue, I have this simple code:
import pandas as pd
import altair as alt
# extract data into a nested list
...
0
votes
2
answers
36
views
Remove gap between two graphs with shared axis
Objective
I want to generate a 'double ended' barchart, showing gained points (of some metric) vis-a-vis missed points, something like this:
Result so far
I managed to do this
import altair as alt
...
1
vote
2
answers
43
views
Altair chart legend for subset of data
As an exercise for learning more advanced altair, I'm trying to generate a simplified version of this chart: https://climatereanalyzer.org/clim/t2_daily/?dm_id=world.
To simplify, I'm using gray for ...
1
vote
1
answer
21
views
Inconsistent graphs with Altair despite same package version
I am working on creating graphs using Altair in different environments with different package sets. Despite ensuring the Altair version is consistent across these environments, I am observing ...
1
vote
0
answers
36
views
Python: ImportError: DLL load failed while importing lib: The specified procedure could not be found
python programming newbie here. I was trying to create a simple histogram with altair using the following code. The dataset is large, around 1,000 rows.
count_chart = alt.Chart(df).mark_bar().encode(
...
0
votes
0
answers
36
views
Wrong rectangle width in altair chart for pandas dataframe
I have pandas dataframe which stores currency rate for given day.
print(df[['Date', 'Currency', 'Rate']].head())
Date Currency Rate
18 2023-12-01 AUD 1.64655
19 2023-12-01 BRL ...
1
vote
1
answer
45
views
Altair: add a line in a grouped bar chart
I have this data that I want to plot. In column 'IPVA' there are [0, 1, 2] as possible values, where 1 and 0 are the data that I want to plot as a grouped bar chart, and the 2 is data that I want to ...
2
votes
1
answer
33
views
Altair not displaying data when changing option on dropdown selector
I want to display counts of a certain feature according to the year with an Altair Chart and I want to do it by selecting year as an option of a dropdown selector. It works fine with the 'None' option ...
0
votes
1
answer
34
views
How to phrase selection_point in altair to do a selection_multi?
Altair now warns that selection_multi is deprecated and tells to use selection_point instead. I tried to replace it with same functionality with no success. How should I do it?
1
vote
1
answer
33
views
Clamping Daily Temperature Plot with Altair on Colab
I'm trying to use altair to recreate the world temperature plot from Climate Reanalyzer: https://climatereanalyzer.org/clim/t2_daily/?dm_id=world. The data is pretty easy to load:
import pandas as pd
...
1
vote
1
answer
23
views
Altair Show Axis Tick Labels As Percentage Point
I would like to format axis tick labels as percentage point.
import altair as alt
from vega_datasets import data
source = data.jobs.url
alt.Chart(source).mark_line().encode(
alt.X('year:O'),
...
1
vote
1
answer
28
views
Altair chart empty by dropdown when other chart is displayed
I want to have two different charts, where in the first I can choose an artist in a legend and in the second chart I want to have a dropdown, that filters a year. In my database I have artists, sales ...
1
vote
1
answer
37
views
Remove gaps with xOffset
Is there a way to not have gaps at non-existing data when using x/yOffset? In the example below, category B only has 1 group (x) and I would like that bar to be centered at the B-tick.
source = pd....
1
vote
1
answer
27
views
Bars not extending the full size in Vega/Altair plot
I'm trying to plot a histogram from pre-binned data using Vega-lite (Actually, Altair in Python, but I got the issue when using Vega directly as well). My dataset contains the following fields:
bin: ...
1
vote
0
answers
44
views
Display only the first value of the dropdown menu. on Altair Chart
I would like my chart to show only the first value of the dropdown menu (the red dots representing "USA" in my case), instead of displaying all of the countries prior to any filtering. I ...
0
votes
1
answer
33
views
Reorder a stacked barplot in altair
So I am making an interactive plot (which is why I'm using altair) and I want to reorder the stacks within each bar to match the legend. I've tried reodering the df, I've tried using the 'sort' ...
3
votes
1
answer
69
views
Altair - Boxplot border to be set black and median line red
I want to set a black border color to the boxplot of a altair graph, i try to add stroke parameter to black on the encoding chanel but this overrided my red median line to black.
This is the code I am ...
0
votes
0
answers
57
views
Altair use multiple selections in multi-layer chart
I would like to have multiple selections in a multi-layer chart. One selection should highlight the closest line and the other should highlight the point on each line closest to the current x position ...
0
votes
0
answers
27
views
Linking Geospatial data to a bar chart
I am attemtping to link two graphs together, a geospatial graph of Philladelphia outlining its districts along with a bar chart that shows the amount of complaints against police per district. This is ...
2
votes
0
answers
24
views
Use value of alt.selection_point as sort field
I have the following facet chart where the order of the facet panels is determined by the column foo. I would like to add a drop-down box where I can select to dynamically update the sort order of the ...
1
vote
1
answer
27
views
Altair Graph in Notebook
When I tried to draw the graph of USGS earthquakes using Altair, it always gives me blank graph. Here are my codes
current_time = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S')
api_url = "https:...
2
votes
1
answer
124
views
Building plots with plotnine and Python
I am looking for a way that I can modify plots by adding to an existing plot object. For example, I want to add annotations at particular dates in a work plot, but want a standard way of building the ...
2
votes
1
answer
53
views
Concatenate two geoshape charts in Altair / Vega-Lite with independent axis?
I am trying to plot two separate geoshape charts and concatenate them together. Below is a MWE of what I am trying to do:
import altair as alt
from vega_datasets import data
import geopandas as gpd
...
1
vote
0
answers
26
views
Mark_text Altair doesn't working with multiple data at same month
I'm writing a code in python with altair and streamlit.
I wrote all the code and have almost everything working, but im having a issue with multiple data sum() mark_text on same month.
Example:
DT ...
1
vote
1
answer
22
views
Altair Chart selected data to graph
I have a dataframe with multiple type-value pairs. Lets say it is:
dt = pd.DataFrame({'date': ['2022', '2023', '2024'], type':['t1', 't2', 't3'], 'value': [1, 2, 3]})
of cause, with much more data ...
0
votes
1
answer
25
views
Altair - Display multiple names in a tooltip from overlapping points
I am working on a visualization to show when pokemon become available in Pokemon Emerald. After scraping data, I am now beating my head against the wall on how to make multiple names show up when ...