altair

Seaborn jointplot axis on log scale with kind="hex"

Seaborn jointplot axis on log scale with kind="hex" Question: I’d like to show the chart below, but with the x-axis on a log scale. df = pd.DataFrame(np.random.randint(0,100,size=(100, 2)), columns=list(‘XY’)) sns.jointplot(data=df,x=’X’,y=’Y’,height=3,kind=’hex’) To be clear, I don’t want to log X first, rather I want the numbers to stay the same but the distance between the axis …

Total answers: 1

How to change decimal format inside a transform_calculate function (Altair)

How to change decimal format inside a transform_calculate function (Altair) Question: I’m trying to limit the numbers after the decimal in the text displayed in my graph, but I’m having a hard time doing so inside a transform_calculate function, this is what it looks like : (I am printing the equation to a linear regression …

Total answers: 1

Displaying specified color in layered Altair charts

Displaying specified color in layered Altair charts Question: I am trying to make a layered chart in Altair and running into an issue. Sample code df = pd.DataFrame(np.array([["A", 2021, 0.9, 0.5], ["A", 2020, 0.8, 0.7], ["B", 2021, 0.6, 0.5], ["B", 2020, 0.8, 0.7]]), columns=[‘Category’, ‘Year’, ‘Count_%_All’, ‘Count_%_Industry’]) domain =[‘A’, ‘B’] range_ = [‘red’, ‘red’] chart_1 …

Total answers: 2

Altair: change point symbol

Altair: change point symbol Question: I use the code below to create this faceted chart: https://vega.github.io/editor/#/gist/a9f238f389418c106b7aacaa10561281/spec.json I would like to use another symbol (a dash in example) instead of the gray points. I found a lot of examples using a field to render a point by value, but I haven’t found how to apply a …

Total answers: 1

Altair Charts containing Encoding of Special Characters

Altair Charts containing Encoding of Special Characters Question: I am trying to plot a chart from a spreadsheet with this code. import pandas as pd import altair as alt crude_df = pd.read_excel(open(‘PET_CONS_PSUP_DC_NUS_MBBLPD_M.xls’, ‘rb’), sheet_name=’Data 1′,index_col=None, header=2) alt.Chart(crude_df.tail(100)).mark_circle().encode( x = ‘Date’, y = r’U.S. Product Supplied of Normal Butane (Thousand Barrels per Day)’ ) I got …

Total answers: 1

Plotting 1:8 attributes on altair

Plotting 1:8 attributes on altair Question: How to plot graph for 1:8 attributes using altair? Here is the link to the dataset. I want to plot an interactive mark_point() graph for various attributes like fresh, frozen, etc, considering the region and channel as filters. The x-axis should have attributes, and the y-axis will have the …

Total answers: 2

Scale Y axis of Altair chart to interactive legend selection

Scale Y axis of Altair chart to interactive legend selection Question: I’ve copied the interactive legend code from here: https://altair-viz.github.io/gallery/interactive_legend.html The difference is that my data has different orders of magnitude for the different series, so it would be nice if, when we select a set of series (shift click), we zoom the graph so …

Total answers: 1

Can mark_geoshape () be used for Canadian Provinces/cities?

Can mark_geoshape () be used for Canadian Provinces/cities? Question: I’m looking to somehow figure out a way to insert a geographic graph of British Columbia which is a part of Canada in my data analysis. I have made this image here explaining what tree is being planted the most in Vancouver Now I want to …

Total answers: 3

Altair choropleth – Get geometry from transform_lookup

Altair choropleth – Get geometry from transform_lookup Question: I am trying to draw a choropleth map of municipalties in Denmark with color encoded as a sum of crimes in that municipalty. I have several entries for each municipalty since the data is over a time-period and types of crime and I have a single geometry …

Total answers: 2