Seaborn bar plot y axis has different values than expected

2024/11/16 16:22:11

The y values in the Seaborn barplot are different than what my data shows.

My data shows:

yearmonth
2018-10     763308.0
2018-11     708366.0
2018-12     703952.0
2019-01     844039.0
2019-02     749583.0
2019-03     826114.0
2019-04     951304.0
2019-05    1042708.0
2019-06    1043556.0
2019-07    1201030.0
2019-08    1065393.0
2019-09     881391.0
Freq: M, Name: csp_workload, dtype: float64

The plot code is:

plt.figure(figsize=(15,5))
sns.barplot(x="yearmonth", y="workload", data = df_all, ci=0)
plt.tight_layout()

The output shows values less than the data. For example, the values for 2018-10 display about 1,800 in the bar plot, but it should be around 763308. Is there something I can do to correct this?

Answer

I tried your code and it worked for me. The only thing I've made was to make sure that yearmonth is being read properly as date format:

pd.to_datetime(df['yearmonth'], format='%Y-%m')

enter image description here

You will notice that the yearmonth column changes to

  0    2018-10-011    2018-11-012    2018-12-01
https://en.xdnf.cn/q/119174.html

Related Q&A

Merge multiple JSON into single one (Python)

I am searching for a way to merge multiple JSONs into a single one. My output is in this format:[{"Nome bollettino": "Bollettino 1"}, {"Causale": "1"}, {"Nu…

I need to filter contents of my text file

I have a text file that I want to loop through, slice some contents, and store in a separate list. The text file contains:blu sre before we start start the process blah blah blah blha end the process b…

How to remove a number from a list that has a range between two numbers? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 6 years ago.Improve…

How do I solve an attribute error?

So like I said before my code (Or my current project that I am working on) is riddled with errors. So far I have at least solved a dozen errors or more and honestly I just give up. I mean God knows how…

Two variables in Django URL

I want a URL something like this:/(category)/(post-slug)On the link this is what I have:{% url blog.category blog.slug %}and for the url.py:url(r^(I DON"T KNOW WHAT TO PUT ON THIS PART TO GET THE …

Python 3.2 Replace all words in a text document that are a certain length?

I need to replace all words in a text document that are of length 4 with a different word. For example, if a text document contained the phrase "I like to eat very hot soup" the words "l…

Python split list at zeros [duplicate]

This question already has answers here:Closed 11 years ago.Possible Duplicate:Remove leading and trailing zeros from multidimensional list in Python if I have a list such as:my_list = [[1,2,0,1], [1,0…

Creating Dynamic Text Using the blit method [duplicate]

This question already has answers here:How to display text with font and color using pygame?(7 answers)Closed last year.Im creating a basic game where a black square moves around the screen. There are…

Regex to match special list items

I have weird list of items and lists like this with | as a delimiters and [[ ]] as a parenthesis. It looks like this:| item1 | item2 | item3 | Ulist1[[ | item4 | item5 | Ulist2[[ | item6 | item7 ]] | i…

How to choose the best model dynamically using python

Here is my code im building 6 models and i am getting accuracy in that, how do i choose that dynamically which accuracy is greater and i want to execute only that model which as highest accuracy."…