Bee swarm plot
Make a bee swarm plot of the iris petal lengths. Your x-axis should contain each of the three species, and the y-axis the petal lengths. A data frame containing the data is in your namespace as df
.
For your reference, the code Justin used to create the bee swarm plot in the video is provided below:
_ = sns.swarmplot(x='state', y='dem_share', data=df_swing)
_ = plt.xlabel('state')
_ = plt.ylabel('percent of vote for Obama')
plt.show()
You can use help(sns.swarmplot)
for more details on how to make bee swarm plots using seaborn.
This is a part of the course
“Statistical Thinking in Python (Part 1)”
Exercise instructions
- Inspect the DataFrame
df
usingdf.head()
. This will let you identify which column names you need to pass as thex
andy
keyword arguments in your call tosns.swarmplot()
. - Use
sns.swarmplot()
to make a bee swarm plot from the DataFrame containing the Fisher iris data set,df
. The x-axis should contain each of the three species, and the y-axis should contain the petal lengths. - Label the axes.
- Show your plot.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create bee swarm plot with Seaborn's default settings
# Label the axes
# Show the plot
This exercise is part of the course
Statistical Thinking in Python (Part 1)
Build the foundation you need to think statistically and to speak the language of your data.
Before diving into sophisticated statistical inference techniques, you should first explore your data by plotting them and computing simple summary statistics. This process, called exploratory data analysis, is a crucial first step in statistical analysis of data.
Exercise 1: Introduction to Exploratory Data AnalysisExercise 2: What is the goal of statistical inference?Exercise 3: Advantages of graphical EDAExercise 4: Plotting a histogramExercise 5: Plotting a histogram of iris dataExercise 6: Axis labels!Exercise 7: Adjusting the number of bins in a histogramExercise 8: Plot all of your data: Bee swarm plotsExercise 9: Bee swarm plotExercise 10: Interpreting a bee swarm plotExercise 11: Plot all of your data: ECDFsExercise 12: Computing the ECDFExercise 13: Plotting the ECDFExercise 14: Comparison of ECDFsExercise 15: Onward toward the whole story!What is DataCamp?
Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.