seaborn

stacked area chart without density on y-axis

stacked area chart without density on y-axis Question: I am wanting to create what looks like a stacked area chart – however, the y-axis of the chart must not be a proportion (between 0 and 1) but rather a count of the number of observations per group per value on the x-axis Example data: import …

Total answers: 1

Only the first row of annotations displayed on seaborn heatmap

Only the first row of annotations displayed on seaborn heatmap Question: As it’s usually advised, I have managed to reduce my problem to a minimal reproducible example: import numpy as np import seaborn as sns import matplotlib.pyplot as plt matrix = np.array([[0.1234, 1.4567, 0.7890, 0.1234], [0.9876, 0, 0.5432, 0.6789], [0.1111, 0.2222, 0, 0.3333], [0.4444, 0.5555, …

Total answers: 5

How to extract xvalues and yvalues from a kdeplot

How to extract xvalues and yvalues from a kdeplot Question: Given that I have a seaborn.kdeplot I want to extract the x and y points. Based on similar questions I have tried the following: points = sns.kdeplot(targets, shade=True, label=’train’).get_lines()[0].get_data() x = points[0] y = points[1] But I’m getting the error Traceback (most recent call last): …

Total answers: 1

Plot datetime object as continuous variable

Plot datetime object as continuous variable Question: Need a hand with some plotting on Seaborn (sns). I’m using Python 3.11.4 on Jupyter Notebooks v6.5.4 via the Anaconda Navigator v.23.7.2, on MacOS. I have a data frame of which a portion is shown below. Behaviour was pre-converted to numeric values using pandas.DataFrame.replace but the issue comes …

Total answers: 1

How to put value over bars when creating many barplots with a loop

How to put value over bars when creating many barplots with a loop Question: How can I put the value over the bars when creating many plots with a loop. The code I am using years = [twenty,twentyone,twentytwo,twentythree] for year in years: plt.ylim(0, 60) ax = sns.barplot(data=year, errorbar=None) ax.set_xticklabels(ax.get_xticklabels(), rotation=45, horizontalalignment=’right’) for i in ax.containers: …

Total answers: 1

custom errorbars for catplot with grouped bars in facets

custom errorbars for catplot with grouped bars in facets Question: pandas 1.5.3 seaborn 0.12.2 My code and part of the data is shown below. I am trying to plot the errorbars precomputed in the dataframe (val_lo,val_hi). It seems that sns.catplot with kind=bar has support using errorbar as mentioned here – how do I get that …

Total answers: 1

Highlight stripplot points based on a condition

Highlight stripplot points based on a condition Question: I am trying to do something like this: import seaborn as sns import matplotlib.pyplot as plt # edit me fig, ax = plt.subplots(figsize=(9, 6)) tips = sns.load_dataset("tips") #sns.stripplot(data=tips, x = [‘f1′,’f2’], y=[combined_df.r1_feature1,combined_df.r2_feature1], hue="size", palette="deep") # wide form with x,y missing params_anno = dict(jitter=0.25, size=5, palette="flare", dodge=True) if(value …

Total answers: 1

Seaborn – how to add a ghost/phantom subplot to a relplot or FacetGrid?

How to add an empty facet to a relplot or FacetGrid Question: I have a relplot with columns split on one variable. I’d like to add one additional column with no subplot or subpanel. To give a clear example, suppose I have the following plot: import matplotlib.pyplot as plt import numpy as np import pandas …

Total answers: 1

Combining video game names to make data frame for sales

Combining video game names to make data frame for sales Question: EDIT: Understood why error bars are showing up, and why I needed to set it to 12 instead of 10, theres 2 repeat names for Grandtheft Auto and Call of Duty, is there a way to combine these two repeats (based on console for …

Total answers: 1

Rotate Label Axis X in a specific subplot using sns.boxplot (seaborn)

Rotate xtick labels of a specific subplot Question: How to rotate in 90° the labels of X axis of subplot 222 (chart 2) and keep using sns.boxplot? fig = plt.figure(figsize=(12, 8)) # CHART 1 fig.add_subplot(221) #sns.countplot(df_train[‘MSZoning’]) sns.boxplot(x=’MSZoning’, y=’SalePrice’, data=df_train) # CHART 2 fig.add_subplot(222) #sns.boxplot(x=’MSZoning’, y=’SalePrice’, data=df_train) sns.boxplot(x=’Neighborhood’, y=’SalePrice’, data=df_train) # CHART 3 fig.add_subplot(223) #sns.boxplot(x=’Neighborhood’, y=’SalePrice’, …

Total answers: 1