Menambahkan gaya

Pengantar Data Science dengan Python

Hillary Green-Lerman

Senior Curriculum Lead, DataCamp

Dan mil yang harus ditempuh

mobil polisi.png

grafik berkendara.png

Pengantar Data Science dengan Python

Mengubah warna garis

plt.plot(x, y1, color="tomato")
plt.plot(x, y2, color="orange")
plt.plot(x, y3, color="goldenrod")
plt.plot(x, y4, color="seagreen")
plt.plot(x, y5, color="dodgerblue")
plt.plot(x, y6, color="violet")

Pengantar Data Science dengan Python

Mengubah ketebalan garis

plt.plot(x, y1, linewidth=1)
plt.plot(x, y2, linewidth=2)
plt.plot(x, y3, linewidth=3)
plt.plot(x, y4, linewidth=4)
plt.plot(x, y5, linewidth=5)
plt.plot(x, y6, linewidth=6)
plt.plot(x, y7, linewidth=7)

Pengantar Data Science dengan Python

Mengubah gaya garis

plt.plot(x, y1, linestyle='-')
plt.plot(x, y2, linestyle='--')
plt.plot(x, y3, linestyle='-.')
plt.plot(x, y4, linestyle=':')

Pengantar Data Science dengan Python

Menambahkan penanda

plt.plot(x, y1, marker='x')
plt.plot(x, y2, marker='s')
plt.plot(x, y3, marker='o')
plt.plot(x, y4, marker='d')
plt.plot(x, y5, marker='*')
plt.plot(x, y6, marker='h')

Pengantar Data Science dengan Python

Mengatur style

Sebelum kode plot lain:

plt.style.use('fivethirtyeight')
plt.style.use('ggplot')
plt.style.use('seaborn-v0_8')
plt.style.use('default')

Pengantar Data Science dengan Python

Ayo berlatih!

Pengantar Data Science dengan Python

Preparing Video For Download...