# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# ## Matplotlib Challenge Problem
# **College Degrees Awarded in Different Fields**
#
# Feel free to make the plots look prettier if you want!!

# +
# Import packages
import matplotlib.pyplot as plt
import numpy as np

# To allow you to see plots in Jupyter Notebook
# %matplotlib inline
# -

# #### 1. Create a pie chart like the one below of the number of bachelor's degrees awarded in different fields in 2014
# ![image.png](attachment:image.png)

# +
# Different majors
majors = [ "Agricultural Sciences", "Biological sciences", "Computer sciences", 
          "Earth sciences","Mathematics and statistics", 
          "Physical sciences", "Psychology", "Social sciences","Engineering"]

# Number of degrees awarded in each major (in the same order as the majors above)
number_of_degrees = [28796,109520,56130,22226,6730,22222,118405,177936,93950]

# +
# Plot the pie chart:

# Plot the title:

# To show the plot
plt.show()
# -

# #### 2. Make a bar chart of the number of women and men who got bachelor's degrees in each of these fields in 2014. 
#
# Hint 1: Use ?plt.bar if you are stuck. 
#
# Hint 2: If you're still stuck, try Googling what you're trying to figure out.
#
# Hint 3: This might help you out: https://matplotlib.org/examples/pylab_examples/barchart_demo.html
#
# ![image.png](attachment:image.png)

# Data on males and females. They are in the same order as the majors above.
male = [13271,44811,45986,4134,12715,13407,27554,80813,75324]
female = [15525,64709,10144,2596,9511,8815,90851,97123,18626]

# +
# Formatting stuff
fig, ax = plt.subplots()

# To plot the bars for males
plt.bar(np.arange(len(male))-0.2,male,width=0.2,color='b',align='center',label='male')

# Use the line above as an example to make the female lines of the bar chart:

# Add a title:

# Add a y-label:

# Formatting stuff
ax.set_xticks(np.arange(len(female))-0.5)
ax.set_xticklabels(majors,rotation=70)

# Show the plot:

# -

# #### 3. If you still have time, try to replicate this: https://matplotlib.org/examples/shapes_and_collections/path_patch_demo.html. Once you've done that, try making your own shape!



StarcoderdataJupyterScriptsDedupFiltered