Untitled
unknown
plain_text
14 days ago
1.6 kB
1
Indexable
Never
import matplotlib.pyplot as plt # Data for charts age_groups = ['13-14', '15-16', '17-18'] respondents = [40, 35, 25] peer_pressure_types = ['Academic Pressure', 'Substance Abuse', 'Social Media Influence', 'Bullying or Teasing', 'Fashion Pressure'] peer_pressure_percentage = [30, 25, 20, 15, 10] areas_of_impact = ['Academic Performance', 'Social Relationships', 'Mental Health'] low_impact = [20, 15, 25] medium_impact = [50, 40, 35] high_impact = [30, 45, 40] # Create subplots fig, ax = plt.subplots(1, 3, figsize=(15, 5)) # Bar chart: Age Distribution ax[0].bar(age_groups, respondents, color='skyblue') ax[0].set_title('Age Distribution of Respondents') ax[0].set_xlabel('Age Group') ax[0].set_ylabel('Number of Respondents') # Pie chart: Types of Peer Pressure ax[1].pie(peer_pressure_percentage, labels=peer_pressure_types, autopct='%1.1f%%', colors=['lightcoral', 'lightgreen', 'lightblue', 'orange', 'purple']) ax[1].set_title('Types of Peer Pressure Experienced') # Stacked bar chart: Impact of Peer Pressure bar1 = ax[2].bar(areas_of_impact, low_impact, color='lightblue', label='Low Impact') bar2 = ax[2].bar(areas_of_impact, medium_impact, bottom=low_impact, color='lightgreen', label='Medium Impact') bar3 = ax[2].bar(areas_of_impact, high_impact, bottom=[i+j for i,j in zip(low_impact, medium_impact)], color='salmon', label='High Impact') ax[2].set_title('Impact of Peer Pressure on Teenagers') ax[2].set_ylabel('Number of Respondents') ax[2].legend() # Show plots plt.tight_layout() plt.show()
Leave a Comment