Calvin
Calvin

Reputation: 19

Creating a seaborn factor plot using two data sets?

I have two data sets:

  1. https://storage.googleapis.com/hewwo/NCHS_-_Leading_Causes_of_Death__United_States.csv
  2. https://storage.googleapis.com/hewwo/BRFSS_Prevalence_and_Trends_Data__Tobacco_Use_-_Four_Level_Smoking_Data_for_2011.csv

From these two data sets, I have created two factor plots

  1. sns.factorplot(x='state', y='deaths', data=death, aspect = 4) plt.xticks(rotation=90)

Result: Data Set 1

  1. smoking['total_smoker'] = smoking['smoke_everyday'] + smoking['smoke_some_days'] sns.factorplot(x='state', y='total_smoker', data=smoking.sort_values("state"), aspect = 3) plt.xticks(rotation = 90)

Result: Data Image 2

I am looking for a way to visually compare the two lines. Is there a way to create one factor plot using data from both sets in order to better compare data per state? Is there maybe a better way to show this visualization than what I am thinking? Apologies if my question is unclear, my experience with these tools are still lacking.

Upvotes: 0

Views: 1185

Answers (1)

Diziet Asahi
Diziet Asahi

Reputation: 40737

just use two lineplot on the same axes:

fig, ax = plt.subplots()
sns.lineplot(..., ax=ax) # first dataset
sns.lineplot(..., ax=ax) # second dataset

Upvotes: 1

Related Questions