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.
Diese Übung ist Teil des Kurses
Introduction to Python for Finance
Anleitung zur Übung
- Draw a scatter plot of
it_peratios with red markers and'IT'label. - On the same plot, add the
cs_peratios with green markers and'CS'label. - Add a legend to this plot.
- Display the plot.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
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')
____