altair

Altair – how to add lines inside chart

Altair – how to add lines inside chart Question: I am trying to add specific lines to a line graph in Altair, going from text to a certain point on the graph. I have added my current output here: I am trying to end up with a chart like the one below, but I can’t …

Total answers: 1

Vertical faceted chart in Altair

Vertical faceted chart in Altair Question: I need to create a faceted chart in altair. I am using the example given in this link (https://altair-viz.github.io/user_guide/compound_charts.html) which places charts horizontally. The code is import altair as alt from vega_datasets import data iris = data.iris.url alt.Chart(iris).mark_point().encode( x=’petalLength:Q’, y=’petalWidth:Q’, color=’species:N’, column=’species:N’ ).properties( width=180, height=180 ) Result – My …

Total answers: 1

AttributeError: 'tuple' object has no attribute python-altair

AttributeError: 'tuple' object has no attribute python-altair Question: I am trying to create a graph using altair in Python and I am getting the error code "AttributeError: ‘tuple’ object has no attribute ‘configure_title" I have tried but search for similar problems but it seems like there not many resources. I have created a graph similar …

Total answers: 2

Altair chart axis is not scaling well with small float numbers like matplotlib

Altair chart axis is not scaling well with small float numbers like matplotlib Question: How can I get Altair to plot the line in the same way as matplotlib (first image) without displaying ranges 0.00 to 0.06 in y axis? See code and example below: import pandas as pd import altair as alt loss_data = …

Total answers: 1

Changing the width of a step in Altair line and area charts

Changing the width of a step in Altair line and area charts Question: I try to build a line chart that displays a value for each month of a full year. I also want to fill months that exceed a threshold. I have an issue with the appearance of the last values of both the …

Total answers: 1

ValueError: class encoding field is specified without a type

ValueError: class encoding field is specified without a type Question: dim_red = TruncatedSVD(n_components=2) data_red = dim_red.fit_transform(tfidf) scatter = alt.Chart(data_red,title="dimensionality reduction",height=400).mark_circle().encode( x=’principal component 1′, y=’principal component 2′, color=alt.Color( ‘class’, scale=alt.Scale(scheme=’blues’)),tooltip=["class"]).interactive() st.altair_chart(scatter)` Asked By: 7F_WZ || Source Answers: This error will generally arise when the encoding names (here ‘principal component 1’ and/or ‘principal component 2’) do not …

Total answers: 1

Python Altair Generate a table on selection

Python Altair Generate a table on selection Question: I have a histogram with a bunch of binned data and I was wondering if it would be possible to say generate a table if I select a bar from the histogram and it would display the data as it is in the original dataframe. Asked By: …

Total answers: 2

Python (Datapane) : How to pass dynamic variables into a datapane report function

Python (Datapane) : How to pass dynamic variables into a datapane report function Question: I am working on a charting module where I can pass on dataframe and the module will create reports based on plots generated by calling few functions as mentioned below. I am using Altair for plotting and "Datapane" for creating the …

Total answers: 2

Is there a way to format tooltip values in Altair boxplot

Is there a way to format tooltip values in Altair boxplot Question: Is is possible to format the values within a tooltip for a boxplot? From this Vega documentation, it appears so, but I can’t quite figure out how to do it with Altair for python from vega_datasets import data import altair as alt source …

Total answers: 2

Is there a way to word wrap or insert a line break with Altair labels?

Is there a way to word wrap or insert a line break with Altair labels? Question: Is there a way to insert a line break when displaying longer labels in Altair? d = {‘source’: [‘short label’, ‘a longer label that needs a line break’, ‘short label’, ‘a longer label that needs a line break’], ‘variable’: …

Total answers: 3