seaborn

Seaborn: cumulative sum and hue

Seaborn: cumulative sum and hue Question: I have the following dataframe in pandas: data = { ‘idx’: [1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10], ‘hue_val’: ["A","A","A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B","B","B","C","C","C","C","C","C","C","C","C","C",], ‘value’: np.random.rand(30), } df = pd.DataFrame(data) Now I want to have a line plot with the cumulative sum over the value by following the "idx" for each "hue_val". So in the end it would be …

Total answers: 2

AttributeError 'tuple' object has no attribute 'get' using Seaborn to bar plot

AttributeError 'tuple' object has no attribute 'get' using Seaborn to bar plot Question: I have an application that’s been giving me some trouble for a bit of time. This is the trace I’m being given: File "C:UsersuserPycharmProjectspythonProjectvenvlibsite-packagesseaborncategorical.py", line 532, in establish_variables x = data.get(x, x) AttributeError: ‘tuple’ object has no attribute ‘get’ I’m trying to …

Total answers: 2

How to format labels in scientific notation for bar_label

How to format labels in scientific notation for bar_label Question: I am plotting data in a seaborn barplot. I want to label something from my pandas dataframe into the bar. I have gotten the labeling part figured out (see code to replicate below), but I still want to convert it to scientific notation. import pandas …

Total answers: 2

How to plot from table with multiple histograms?

How to plot multiple histograms from a dataframe Question: I have a table with following format: df = pd.DataFrame({‘Bins’: [‘Bin1′,’Bin2′,’Bin3’], ‘hist_A’: [10,5,10], ‘hist_B’: [1,5,6], ‘hist_C’: [1,8,6]}) Where the values are the ‘weights’ or ‘frequency/counts’. How can I plot these histograms in one Seaborn displot() with ‘hue’ and ‘col’ faceting? Asked By: mrLimpio || Source Answers: …

Total answers: 2

What is the difference between these seaborn.boxplot implementations?

What is the difference between these seaborn.boxplot implementations? Question: My current prof entered this code in our tutorial jupyter notebook: f = plt.figure(figsize=(24, 4)) sb.boxplot(data = hp, orient = "h") but in previous year’s tutorial videos, this was the code: f, axes = plt.subplots(1, 1, figsize=(24,4)) sb.boxplot(hp, orient = "h") I have tried to run …

Total answers: 1

Add a point to seaborn stripplot that signifies mean for each category

Add a point to seaborn stripplot that signifies mean for each category Question: I am using seaborn to create a stripplot for three conditions. The example data look like: df = pd.DataFrame( { ‘bill’: [50, 45, 33, 23, 22, 34, 54, 22, 54, 76], ‘day’: [‘sat’, ‘sat’, ‘sat’, ‘sat’, ‘sat’, ‘sun’, ‘sun’, ‘sun’, ‘sun’, ‘sun’], …

Total answers: 1

TypeError: barplot() takes from 0 to 1 positional arguments but 2 were given

TypeError: barplot() takes from 0 to 1 positional arguments but 2 were given Question: Can someone tell me whats wrong here #stemming all the words to their root word stemmer = SnowballStemmer(language=’english’) stem=[] for word in lines: stem.append(stemmer.stem(word)) stem[:20] #removes stopwords (very common words in a sentence) stem2 = [] for word in stem: if …

Total answers: 1

Adding hatch to Seaborn multi-boxplot

Adding hatch to Seaborn multi-boxplot Question: In the chart below, I want to add hatch (‘/’) only to the ‘rest’ category in both boxlots. I will be glad if you help I add the sample codes below: import seaborn as sns exercise = sns.load_dataset("exercise") df1=exercise.loc[(exercise["diet"]=="low fat"),:] df2=exercise.loc[(exercise["diet"]=="no fat"),:] fig, axes = plt.subplots(1, 2) ax1=sns.boxplot(x=’kind’, y=’pulse’, …

Total answers: 1

Seaborn correlation matrix in Python: masking out based on p-values and correlation

Masking correlation matrix based on p-values and correlation Question: Based on this answer I have the following code to draw a correlation matrix which only plots data where p<0.05: import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt from scipy import stats # Simulate 3 correlated variables num_samples …

Total answers: 1