Complete the code to import the seaborn library as sns.
import [1] as sns
Seaborn is imported as sns to use its plotting functions like FacetGrid.
Complete the code to create a FacetGrid object using the 'tips' dataset, grouping by 'time'.
g = sns.FacetGrid(tips, col=[1])The col parameter defines the column variable to create separate panels. Here, it's 'time' (Lunch or Dinner).
Fix the error in the code to map a scatter plot of 'total_bill' vs 'tip' on the FacetGrid.
g.map(plt.scatter, [1], 'tip')
The variable names must be strings when passed to map. So 'total_bill' should be in quotes.
Fill both blanks to create a FacetGrid grouped by 'sex' and map a histogram of 'total_bill'.
g = sns.FacetGrid(tips, col=[1]) g.map(plt.hist, [2])
The FacetGrid is grouped by 'sex' (male/female), and the histogram is plotted for 'total_bill'. Both must be strings.
Fill all three blanks to create a FacetGrid grouped by 'smoker' and 'day', map a scatter plot of 'total_bill' vs 'tip', and add a title.
g = sns.FacetGrid(tips, row=[1], col=[2]) g.map(plt.scatter, [3], 'tip') g.fig.suptitle('Total Bill vs Tip by Smoker and Day') g.fig.tight_layout()
The FacetGrid is created with rows by 'smoker' and columns by 'day'. The scatter plot maps 'total_bill' on x and 'tip' on y. The title is added to the figure.