ไลบรารีกราฟ Python ของ Plotly ทำให้กราฟเชิงโต้ตอบคุณภาพสิ่งพิมพ์ออนไลน์ กราฟนี้ใช้เป็นหลักเมื่อเราต้องการสร้างแผนภาพเส้น แผนภาพกระจาย แผนภูมิพื้นที่ แผนภูมิแท่ง แถบข้อผิดพลาด แผนภาพกล่อง ฮิสโตแกรม แผนที่ความหนาแน่น แผนผังย่อย แผนภูมิหลายแกน แผนภูมิขั้วโลก และแผนภูมิฟอง
Seaborn เป็นห้องสมุดสำหรับสร้างกราฟิกเชิงสถิติใน Python มันถูกสร้างขึ้นบน matplotlib และถูกรวมเข้ากับโครงสร้างข้อมูลของแพนด้า

1. เรานำเข้า Seaborn ซึ่งเป็นห้องสมุดเดียวที่จำเป็นสำหรับตัวอย่างง่ายๆ นี้
import seaborn as sns
2. เราใช้ธีมเริ่มต้น มาตราส่วน และจานสีเริ่มต้น
sns.set()
3. เราโหลดชุดข้อมูลตัวอย่างชุดใดชุดหนึ่ง
tips = sns.load_dataset("tips")
4. เราวาดพล็อตแบบกระจายเหลี่ยมเพชรพลอยพร้อมตัวแปรความหมายหลายตัว
โค้ดตัวอย่าง
# This Python program will illustrate scatter plot with Seaborn # importing modules import matplotlib.pyplot as plt import seaborn as sns # values for x-axis x=['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] # valueds for y-axis y=[10.5, 12.5, 11.4, 11.2, 9.2, 14.5, 10.1] # plotting with seaborn my_plot = sns.stripplot(x, y); # assigning x-axis and y-axis labels my_plot.set(xlabel ='Day Names', ylabel ='Turn Over (In Million Dollars)') # assigning plot title plt.title('Scatter Plot'); # function to show plot plt.show()
ผลลัพธ์
