How would I replicate this boxplot from Minitab on Seaborn? - python

This is a graph that I got from Minitab that I would like to replicate this on Seaborn for better quality.
Boxplot from Minitab
My data looks like this:
I tried using a FacetGrid and then mapping with sns.boxplot but that wasn't working.
Should I try to use groupby on the Layer thickness instead?
I am a beginner in data viz using python and any help on this would be great.

Related

Error when plotting line graph using seaborn: If using all scalar values, you must pass an index

I am trying to make a more aesthetically pleasing graph for a project and was told that seaborn would make beautiful plots but I am having trouble with it as it returns the error: If using all scalar values, you must pass an index. I'm not sure why there is this error as I am able to plot a regular graph using the same dataframe.
This is the dataframe that I am using:
and I have successfully created a graph:
ax = data1.plot(xlabel='Year', ylabel='Electricity generation capacity', figsize=(15,10), marker='.')
ax.legend(title='Electricity generation capacity by Year', bbox_to_anchor=(1, 1.02), loc='upper left')
However, the graph is quite ugly as you can barely see the trend of the bottom three lines. (I do not know if seaborn will help with this issue as I am rather new to python and am unfamiliar with data visualization using python.)
Perhaps my code is wrong but when I try to make a graph, sns.lineplot(data1) , it returns an error as mentioned above.
Please let me know how I can solve this issue (Or if I can create a better-looking graph without seaborn, please teach me). Thank you.
From your screenshot it seems like the Year is the dataframe index. Try this:
sns.lineplot (data=data1, x=data1.index)

How can I get a plot with errorbars in Pandas?

I have a set of data held in a dataframe, with another dataframe with the associated errors. I would want to plot this with seaborn, but I can't seem to find a way to do this. I can get a scatterplot, but not with errorbars.
I would want something like This
Which was produced with Matplotlib. Although if I can't plot the lines that is ok as well. I am able to get a basic scatterplot with the sns.scatterplot() method, but can't find any way to add the errorbars to it. Does anyone know how to do this in seaborn?
Thanks

Bokeh line chart is plotting weird

I am trying to plot chart in my data science project. And I want to plot chart in this way
which is produced by Matplotlib library. And now I want to plot in the same way. But it gives me this way in bokeh.
My data for this in the form of python list and it is as below:
ages = [45.0,50.0,55.0,40.0,60.0,35.0,65.0,30.0,70.0,25.0,75.0,20.0,80.0,85.0,15.0,90.0,10.0,0.0]
ageCounter = [4466,4270,3824,3576,3240,2850,2527,2358,1968,1544,981,655,419,149,132,80,17,2]
Is there any thing I am missing.
Thanks in advance.
You need to sort the arrays together by age. Bokeh plots the points in the order you pass them in. The data above is out of order which explains the "zigzag".

Seaborn keeps flipping my rows for multi-graphs

I'm using Seaborn for some data exploration and am using the catplot functions. When I use col='something' to create multiple graphs, I am running into an issue where the variable names of one plot do not match up with another. The colors are the same. I've tried using the order=list, but nothing seems to work.
An example would be
sns.catplot(x=variable, y=other_variable, data=df, col=something, kind='bar')
and I get something like this.

Scatter plot in pandas different from that of Matplotlib

Here's the result of scatter plot using Matplotlib
And now here's the result of calling scatter plot using Pandas
Is there bug in Pandas scatter function or is it supposed to work like this?
I think the grey area you see is the boundary of each point. Use the argument edgecolors='none' or edgecolors='black' to get the same result as you get with matplotlib (see also http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.scatter)

Categories