MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Introduction to Python for Finance

Lihat Kursus

Petunjuk latihan

  • 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.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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')
____
Edit dan Jalankan Kode