1

I'm looking to plot per year the distribution of sunshine depending on the season with seaborn.

sns.displot(x = 'Sunshine', data = dviz, kind ='kde', hue = 'season', col = 'year')

Here is the dataset : enter image description here

And the displot returned are :

enter image description here

Columns 'year' contains year from 2009 to 2020 and I want to plot only for last 5 years ( 2016, 2017, 2018, 2019, 2020).

This is corresponding to the last five plot

Do yo know how to select the values that I want for the col?

Thank you !

4
  • 1
    It seems your question has nothing to do with seaplot or plots in general. It has to do with data engineering and being able to filter a dataset based on a particular condition. Commented Jul 17, 2021 at 15:03
  • 1
    It is always good to put some sample of your data to ease the support Commented Jul 17, 2021 at 15:03
  • @karlphillip I don't understand why you are telling this, I think the issue could be resolved by a good use of seaborn distplot or Facetgrid Commented Jul 17, 2021 at 15:10
  • 1
    @Ahribba Alex answer is correct and proves the point I made earlier. The reason I mentioned the obviousness of the problem (though it didn't made sense to you at first), is that a good question title with a solid description of the issue, along with a reproducible example, has a much higher probability to get people to answer your question! Otherwise, it can become quite a long cat & mouse game on the comment section for us to understand what the issue is all about. That's also why many people don't bother answering questions from new users. Welcome to Stackoverflow! Commented Jul 17, 2021 at 17:53

1 Answer 1

1

You could simply filter the data as Crocs mentioned:

dviz_selected = dviz.loc[(dviz["year"] >= 2016) & (dviz["year"] <= 2020)]

sns.displot(x = 'Sunshine', data = dviz_selected, kind ='kde', hue = 'season', col = 'year')
Sign up to request clarification or add additional context in comments.

1 Comment

It works well. Thank you. Thanks to @Crocs also :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.