bar-chart

Using plotly express px.bar causes a shift in output

Using plotly express px.bar causes a shift in output Question: I am trying to print a bar chart using plotly express (px.bar). It is a yearly set of data from 2015 to 2022 but gets plotted from 2016 to 2023. Not sure why… Code to plot yearly returns. # plotting the yearly % returns fig …

Total answers: 2

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

How to make a barplot not based of labels?

How to make a barplot not based of labels? Question: I don’t have a dummy code so I will try to explain it as good as I can. If no success I will try to think of a code to make it more clear. My question is regarding making a barplot. I’d like to make …

Total answers: 1

Calculate the percent occurrence of values from summed rows and plot as bars

Calculate the percent occurrence of values from summed rows and plot as bars Question: I have survey data based on 6 questions, where each column corresponds to one question (case), and each row corresponds to one survey respondent who answered all 6 questions. 1.0 means the respondent would give fluid, and 0.0 means they would …

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

Python – Two different bar charts next to each other

Python – Two different bar charts next to each other Question: I am using matplotlib to analyze my data. For this I created a dataframe with following structure: merge.set_index(‘index’, inplace=True) print(merge) username mentioned_user index matthiashauer 73 10 derya_tn 67 5 renatekuenast 36 9 ralf_stegner 35 73 mgrossebroemer 33 12 … … … katrinhelling 1 1 …

Total answers: 1

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

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

How to plot multiple pie chart or bar chart from multi-index dataframe?

How to plot multiple pie chart or bar chart from multi-index dataframe? Question: Dataframe is as below. There are multiple index as category_1 & category_2 and two column as count & % I need to draw multiple (for each category_1) pie chart for category_2 & % and bar chart for category_2 & count. count % …

Total answers: 3

how to center bars on a bar chart when one of the bars is none valued

how to center bars on a bar chart when one of the bars is none valued Question: My problem is that one of the bars is not centered as the bar that is probably next to it technically (it is none) is somehow interfering or maybe not i don’t know. my code is: import matplotlib.pyplot …

Total answers: 1