Aan de slagGa gratis aan de slag

Plot P/E ratios

Let's take a closer look at the P/E ratios using a scatter plot for each company in these two sectors.

The arrays it_pe and cs_pe from the previous exercise are available in your workspace. Also, each company name has been assigned a numeric ID contained in the arrays it_id and cs_id.

Deze oefening maakt deel uit van de cursus

Introduction to Python for Finance

Cursus bekijken

Oefeninstructies

  • Draw a scatter plot of it_pe ratios with red markers and 'IT' label.
  • On the same plot, add the cs_pe ratios with green markers and 'CS' label.
  • Add a legend to this plot.
  • Display the plot.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

import matplotlib.pyplot as plt

# Make a scatterplot
plt.____(it_id, it_pe, ____, ____)
____(cs_id, cs_pe, ____, ____)

# Add legend
____

# Add labels
plt.xlabel('Company ID')
plt.ylabel('P/E Ratio')
____
Code bewerken en uitvoeren