Questions tagged [altair]
Altair is a declarative statistical visualization library for Python, based on Vega-Lite. Please include code and sample data in your question.
1,206
questions
1
vote
1
answer
29
views
What will be the pandas equivalent of the following altair transformation?
I've been trying to create a parallel set chart with the help of altair, but am unable to understand what the below mentioned code means, esp. the transform_window function. I've looked up the ...
0
votes
0
answers
21
views
How to find current value of selector in altair
Is there any way to extract the current value of a selector? I have a chart that is too big, so it requires a lot of memory and I cannot have it loaded all at once, so I plan to do it in parts, but I ...
1
vote
1
answer
23
views
Altair- How to Display All Axis
I have the code below and how can I reorder the days of the week to the proper order, and make sure the weeks of the year with missing data get displayed
This is the code I have
import pandas as pd
...
0
votes
0
answers
31
views
Python creating vizualizations with Altair. KeyError: "'config'"
I'm new to python and I'm trying to create a visualization of altair charts in my program (I take the data for the charts from a json file). Getting KeyError: "'config'" or KeyError: "'$...
1
vote
0
answers
10
views
How do I edit a subplot axis on a Facet plot in altair?
After I use a facet to generate several subplots on my data, how can I edit the y-axis label on one of the subplots? I tend to need to do this because I plot multiple metrics, and some of them are %'s,...
-1
votes
0
answers
33
views
How to recreate matplotlib in altair
I've created a script in Python that takes ONS data in the UK and can create simple timeseries in matplotlib like this...
I tried to look at the top increasing trending names - although the numbers ...
1
vote
0
answers
43
views
Can Altair do a window transform with interactive frame?
I want to create a line chart in altair that has the raw data as background, and an interactive rolling average on top of that. This is possible in vega based on the documentation for window ...
0
votes
1
answer
55
views
Altair chart out of container while container_width set true
Summary
Problem is my chart has many columns, is there a way my chart's width is set to his container because it's out of his container now.
Steps to reproduce
Code snippet:
from vega_datasets import ...
0
votes
1
answer
33
views
Streamlit Altair Bar chart Y axismax min
According to this answer, I'm suppose to use scale = alt.Scae(domain=[0,1.4]) to scale the axis to my preference. But when I do it, the entire bar chart moves lower, hiding the entire x-axis. Why is ...
0
votes
0
answers
21
views
change x-axis based on selection in altair
I've created the following visualization in altair: (https://i.stack.imgur.com/8WTPi.png
As you can see, different selections from the drop down menu have different ranges of values on the x-axis (...
0
votes
0
answers
21
views
How can I print the value of a clicked point in altair_viz scatter plot?
I have created a scatter plot from a dataframe. One of the columns contains large amounts of text, which isn't feasible to display in the hover bubble.
I would like to be able to click on a point and ...
0
votes
0
answers
31
views
Circular dendrogram with Altair
I'm trying to build a circular dendrogram with Python.
This example from Vega is perfect: https://vega.github.io/vega/examples/radial-tree-layout/
But after several days, I've been unable to reproduce ...
1
vote
0
answers
37
views
How to solve altair problems in python
I want to make a chart with 2 values using altair, but the chart result did not meet my expectation. I want to make a chart with 2 different colors and a legend for describing each value. I tried this ...
3
votes
1
answer
153
views
Altair python slider not working, module 'altair' has no attribute 'param'
I am trying to use a slider on an interactive chart so that certain points are highlighted either red or blue depending on the slider which changes 'count'.
I have these 2 lines:
slider = alt....
0
votes
0
answers
63
views
How to generate popup on folium map only when clicking on the marker
So here is the issue that I have... I've been working with creating maps with Folium using Python code. It's a great tool. As I'm advancing I'm encountering certain problems. I've generated a map with ...
0
votes
1
answer
28
views
Vega-Altair Conditional Coloring of A line in an multiline chart
I am new user of altair and was trying to understand it's Usage. On the classic cars dataset.
On the classic cars dataset
SO while doing this I said let's build a linechart and color it by Origin.
alt....
0
votes
0
answers
71
views
Altair not pulling data from json, which is created with Altair
I am using polars to melt a dataframe, convert pandas, then plot with altair. It is a large dataframe, but I have implemented the techniques present here and here to manage the large amount of data ...
0
votes
1
answer
53
views
Vegafusion No module named 'vl_convert' error python
I am using vegafusion with altair and python to display a chart that won't show because of the max rows limit, but I have installed vegafusion and imported and enabled it.
When I go to run the ...
0
votes
1
answer
33
views
schemaValidation error when using csv file with altair
I am using altair with python to visualise a map.
with open('cities.csv', encoding='utf-8') as f:
city = alt.Chart(f).mark_circle().encode(
latitude='latitude:Q',
longitude='longitude:Q',
...
0
votes
1
answer
75
views
Altair multiple graphs from single data frame
My data frame looks like
testname| owner| seed| duration| status| module| date |
t1 | ram | 101 | NA | PASS | M_1 | 03_01_2023_15_42 |
t2 | ram | 101 | NA | PASS |...
1
vote
1
answer
23
views
Altair make axis lines thicker
I have an altair chart that looks like below. I would like to make the axis lines thicker as I (read: the reviewer of my paper) feel the current lines are too thin and are not easily visible on the ...
1
vote
1
answer
25
views
Add vertical space within legend
I have a large plot with a long legend. Is it possible to add vertical space after certain items?
For instance, if I use the plot shown here as an example, is it possible to add additional vertical ...
0
votes
1
answer
29
views
Area Chart in Altair with Negative Numbers: Fill 'below' the line, not 'above'
I have a set of data that is all negative values. I want to 'fill' the area under the curve, rather the above the curve to the 0 line (default behavior, as seen in the image).
Provided is a simplified ...
1
vote
1
answer
37
views
Altair graph with conditional tooltip
I want to use 'tooltip' to show information depending on the type of point in the plot. I noticed that 'tooltip' accepts 'condition'. Therefore, I'm trying to use 'tooltip' together with 'alt....
1
vote
1
answer
38
views
Using Altair and 'mark_point' to highlight area in a faceted graph
I'm trying to use 'mark_point' to highlight an area in a faceted graph, using Altair. Because the graph is faceted, I need to use the same dataset for plotting the points and the highlighted area. ...
0
votes
0
answers
33
views
Renderer has not been properly enabled for the frontend that I´m using
Sorry this could be a easy doubt but I´m new using python and making code and...
I'm having trouble displaying the following graphs:
The message error is the following :
<VegaLite 4 object>
If ...
0
votes
0
answers
19
views
how do I make these two charts responsive using vconcat in jupyter-flex?
I’m trying to understand how I can make these two charts responsive, the idea is to put them in a dashboard generated through Jupyter-Flex.
# Create a selection that chooses the nearest point & ...
0
votes
1
answer
40
views
Using Altair to highlight area in faceted charts (similar to axhspan or axvspan)
I'm trying to include a yellow band in a faced graph using Altair, like in the image below:
However, I can not find a way to include this yellow band (in the graph above I used Photoshop). This ...
0
votes
1
answer
24
views
How to apply color scale by field range?
In vega-lite I'm able to apply color scale by field range, I'm able to use the field values of color field to color my chart (this is the sample code).
I'm not able to rewrite in Python/altair, the ...
0
votes
0
answers
36
views
Altair plot using facet, column and shaded area
I'm trying to plot a graph using Altair that takes advantage of both columns and facet options, however, whenever I use columns, I can not use facet. I can also not manage to include a background ...
0
votes
1
answer
35
views
Tooltip not showing in Altair plots
Tootip not showing up and and getting an error message
data set
coding
lcp = alt.Chart(lc).mark_bar().encode(alt.X('Plant ID'),
alt.Y('perimeter cm', tooltip=['Plant ID']))
lcp
try to include tooltip ...
0
votes
1
answer
80
views
Python Altair Radial Plot for Multiple Variables
I'm trying to make a radial plot using altair and streamlit to display two parameters about various car manufacturers. My data frame looks like this:
make
count
value
value_int
MERCEDES-BENZ
8637
...
0
votes
0
answers
19
views
Display first ten cols of Altair chart if no user selection?
My graph contains 90 rows of different companies. It's controlled by a dropdown menu that allows users to select an individual company. However, until a user selects a value from the dropdown, ALL the ...
0
votes
1
answer
35
views
Plotting a graph using cells containing two variables
I have a dataframe like this:
import pandas as pd
import numpy as np
date_vals = ['2022-01-01', '2022-01-02', '2022-01-03', '2022-01-04', '2022-01-05',
'2022-01-06', '2022-01-07', '2022-...
1
vote
1
answer
28
views
TypeError: 'UndefinedType' object is not callable
I'm getting a TypeError: 'UndefinedType' object is not callable when running the following Altair code.
import altair as alt
from vega_datasets import data
cars = data.cars()
alt.Chart(cars)....
0
votes
1
answer
54
views
Pie Chart with Labels and facet in altair: not able to proper render the value labels
Using the single chart example, I have a label for each piece of cake.
If I try to transform it in a faceted chart using this code
df=pd.read_csv("input.csv",keep_default_na=False)
base=...
0
votes
1
answer
22
views
Altair how to use nested arguments in a custom theme? (facet headers)
I'm trying to create a custom theme in Altair where one of the things I'm changing is the font of the headers in a facet chart. I'm not sure if I'm formatting the nested argument wrong, or if it's ...
2
votes
0
answers
33
views
Altair + panel: chart dynamic dropdown filter doesn't work
I almost have it, but the filter selection only works when executing the cell in jupyter. It doesn't get updated when the dropdown selector is used.
I have three parts:
A scatterplot that has to have ...
1
vote
1
answer
25
views
Remove blank lines in Gantt chart when using Facets in altair
The following code:
import altair as alt
import pandas as pd
source = pd.DataFrame([
{"task": 1, "start": 1, "end": 3, "group": 1},
{"task": ...
0
votes
0
answers
14
views
How can I tie color and strokeDash to a dynamic number of series in runtime?
I'm trying to create a dynamic line chart with multiple series picked by user at runtime (which metrics to chart) but how do I allocate a specific color and strokeDash to specific series? I look for ...
1
vote
1
answer
26
views
Altair: rotate shapes in scatterplot
Using this as an example (my plot is actually a bit more complicated, therefore this example):
import altair as alt
from vega_datasets import data
source = data.stocks()
x = alt.Chart(source)...
0
votes
1
answer
47
views
Repeated values in date axis
I'm trying to make a bar graph which has its X axis's type as time. I formatted it using 'utcyearmonth', but the X axis's label repeats values.
Any ideas on what I'm doing wrong?
The code I have ...
1
vote
1
answer
85
views
Altair Chart Conditional Text Opacity
Given the image below some values are smaller than 50. I want values smaller than 50 not to be on the chart.
Is it possible to hide, remove or shrink opacity for this?
Code is:
import altair as alt
...
0
votes
0
answers
27
views
Using Multiple Transform filters in Altair with Django
In the code below I am using 3 charts with 2 charts having selection interval added. I would like to add a transform_filter to the other chart such that it should work in below cases:
either ...
1
vote
1
answer
61
views
groupby by multiple variables using Altair
I have a dataset that contains timestamps roughly every 15 minutes for several years, weather stations (two stations), solar zenith angle (sza), and categorical column that contains values such as TN, ...
0
votes
0
answers
8
views
altair interactive plot radio butten hightlighting mark
plot_image
ploting scatter plot using altair radio butten highlighting.
My concern is the hiding highlight marks from non-selected element which is corresponding light grey marks
Are there option ...
0
votes
0
answers
13
views
altair interactive plot radio butten mark
ploting scatter plot using altair radio butten highlighting.
My concern is the hiding highlight marks from non-selected element which is corresponding light grey marks
Are there option that ...
0
votes
0
answers
79
views
Render multiple Altair charts into a webpage
To create one webpage with multiple Altair charts, all nicely formatted and easily deployable to GitHub Pages, I am trying to get several tools to work together. I am rendering the charts' json into ...
0
votes
1
answer
30
views
Manually set an Altair drop down value scale
I have a chart of Washington, DC condo prices and I'd like one of the drop down options to be "Year built". This is my code so far:
dropdown = alt.binding_select (options=["Square Feet&...
0
votes
1
answer
55
views
Align rotated labels of Altair boxplot
I'm plotting a boxplot graph using Altair to divide the data into groups (similar to what was done here: Altair boxplot with nested grouping by two categorical variables) . The code I have is below:
...