Python Seaborn - How to Create Strip Plot in Python

avatar

In this plot How to Create Strip Plot in Python. Previously we looked at Heatmap in Python Seaborn Library. That chart was handy for the population based charts and the charts which make use of the area and the specific points in the heatmap where it shows the points for the plot. In that context you I'd say that this new strip chart is also worth trying out. So check earlier tutorial for the heatmap.

Strip plot can be really good for visualizing the observations within your data set and you would be able to get the representation of the underlying distribution. This is something you can check out as we plot the strip chart. A lot of the current tutorial is based on fundamental. I think I make sure to get the simple dataset here for you. Like making use of the titanic dataset would be worth making use of for most of the scenarios.

So the titanic dataset is something you can check out for you in the github. Find here and download. The point is that you have to read this chart and also you can use this in the data and experiment with variety of the color palette, legend and other configuration parameter for the chart too.

tidata.png

And I have created a video to give you an overview on How to Create Strip Plot in Python using Seaborn. You should give this below video a look.



First thing you have to check if you have the python version. So you can check that out with the python commands.

python --version

And now we would be checking out the library install command too.

pip install numpy pandas jupyter seaborn matplotlib

Now let's take a look at how to open the jupyter notebook command.

jupyter notebook

Load the Library

Use the below commands to load the library.

import seaborn as sns
import matplotlib.pyplot as plt

Load the Dataset

Use the below code for loading the dataset.

titanic=sns.load_dataset("titanic")
titanic.head()

Plot the Strip chart

Here we have the data for the plotting and now you can plot the strip chart.

sns.stripplot(x="age", y="who", hue="alive",data=titanic)
plt.show()

Check the code below for complete reference.

import seaborn as sns
import matplotlib.pyplot as plt
titanic=sns.load_dataset("titanic")
titanic.head()
sns.stripplot(x="age", y="who", hue="alive",data=titanic)
plt.show()

For the image reference you can check out the code.

stripchart.png

Next thing now that we have the jupyter python notebook open. I am going to add the command that would run the code and also show the plot image below the code. So you can check the plot image below. Here we are just hitting the run button so no need to push for the command.

jupyter.png

As you can see the plot above. There are lot of things that you can do here. Like say you can add the oritnetation from horizontal to vertical. You can change the color, add groups for the data points, add legend and also add variety of the points that you can use with the plot chart. This is one thing you would love as you experiment there. I have noticed that plot by group is something you should definitely check out.

Next you have to like, share and subscribe. You would be able get the notification of the content that I am creating here. And so you should definitely go ahead, like and share too. So some of the time this is a good platform for you to check my new content. Check the above video for the channel link and from there you would go ahead for the content and also for the subscription and likes there. I have been going into the cloud content soon so these are last videos in the series.

If you happen to like this content, do give me feedback over there and that would help me improve my efforts in near future.



0
0
0.000
2 comments
avatar

Congratulations @devpress! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You have been a buzzy bee and published a post every day of the week.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out our last posts:

It's the Christmas season: give your friends a gift
0
0
0.000
avatar

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

0
0
0.000