Skip to content

Instantly share code, notes, and snippets.

@smzn
Created January 22, 2024 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smzn/bf80863b48d56fbfa9edad8bd17ef79c to your computer and use it in GitHub Desktop.
Save smzn/bf80863b48d56fbfa9edad8bd17ef79c to your computer and use it in GitHub Desktop.
2値データヒストグラム
import matplotlib.pyplot as plt
import seaborn as sns
# Set the aesthetic style of the plots
sns.set_style("whitegrid")
# Selecting a subset of columns for plotting histograms
# Excluding binary columns for more meaningful histograms
hist_columns = [
"Diabetes_binary",
"HighBP",
"HighChol",
"CholCheck",
"Smoker",
"Stroke",
"HeartDiseaseorAttack",
"PhysActivity",
"Fruits",
"Veggies",
"HvyAlcoholConsump",
"AnyHealthcare",
"NoDocbcCost",
"DiffWalk",
"Sex"
]
# Plotting histograms for selected columns
plt.figure(figsize=(20, 10))
for i, column in enumerate(hist_columns, 1):
plt.subplot(3, 5, i)
sns.histplot(data[column], kde=False, bins=2)
plt.title(column)
plt.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment