Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีแสดงข้อมูลภาพด้วย Seaborn Library ใน Python

Machine learning สร้างโมเดลจากข้อมูล ข้อมูล input ควรเข้าใจง่าย Seaborn visualize ข้อมูล มี theme และ high-level interface ปรับแต่งรูปแบบและพฤติกรรมข้อมูล มี 'set_style()' ตั้ง theme ของ plot

ตัวอย่าง

import numpy as np
from matplotlib import pyplot as plt
def sine_plot(flip=1):
    x = np.linspace(0, 9, 50)
    for i in range(1, 7):
        plt.plot(x, np.sin(x + i * .68) * (6 - i) * flip)
import seaborn as sb
sb.set_style("whitegrid")
print("The data is being plotted ")
sine_plot()
plt.show()

ผลลัพธ์

วิธีแสดงข้อมูลภาพด้วย Seaborn Library ใน Python

คำอธิบาย

  • นำเข้าแพ็กเกจ
  • สร้างข้อมูลด้วย 'sine_plot'
  • ใช้ 'set_style' ตั้งรูปแบบ plot (whitegrid)
  • กำหนดใช้ seaborn plotting
  • แสดงภาพ

Seaborn styles: white, dark, whitegrid, darkgrid, ticks ใช้ set_style() เลือกได้