roberthsu2003 / __2024_04_17_mon_wed__

Python與AI人工智慧開發入門
25 stars 4 forks source link

建立一個Pie圖表,顯示廠商的市場佔有率 #23

Open roberthsu2003 opened 1 month ago

roberthsu2003 commented 1 month ago
labels = ['Nokia', 'Samsung', 'Apple', 'Lumia']
values = [20, 30, 45, 10]

參考的網址

https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.pie.html

截圖 2024-06-05 晚上9 20 17
chesterXalan commented 1 month ago
import matplotlib.pyplot as plt

labels = ['Nokia', 'Samsung', 'Apple', 'Lumia']
values = [20, 30, 45, 10]
explode = [0.3, 0, 0, 0]
colors = ['yellow', 'green', 'red', 'blue']

figure = plt.figure(figsize=(5, 5), dpi=200, facecolor='#ADD8E6')
axes = figure.add_subplot(1, 1, 1)
axes.pie(values,
         labels=labels,
         explode=explode,
         colors=colors,
         autopct='%.1f%%',
         startangle=180,
         shadow={'ox': -0.01, 'oy': -0.01})

plt.show()

output

Tina54321 commented 1 month ago
import matplotlib.pyplot as plt

labels = ['Nokia', 'Samsung', 'Apple', 'Lumia']
values = [20, 30, 45, 10]
explode = (0.3, 0, 0, 0)
color = ['yellow', 'green', 'red', 'blue']

figure = plt.subplot()
figure.pie(values, labels=labels, explode=explode, autopct='%1.1f%%', shadow=True, startangle=180, colors=color)

plt.show()

image

Tony840705 commented 1 month ago
import matplotlib.pyplot as plt

labels = ['Nokia', 'Samsung', 'Apple', 'Lumia']
values = [20, 30, 45, 10]
explode = [0.3, 0, 0, 0]
colors = ['yellow', 'green', 'red', 'blue']

figure = plt.figure(figsize=(5, 5), dpi=150, facecolor='#FAF4FF')
axes = figure.add_subplot(1, 1, 1)
axes.pie(values,labels=labels,explode=explode,colors=colors,autopct='%.1f%%',startangle=180,shadow={'ox': -0.01, 'oy': -0.01})
axes.set_title('Market Survey',color ='black')

plt.show()

output

PercJK commented 1 month ago
#labels = 'Nokia', 'Samsung', 'Apple', 'Lumia'
#values = [20, 30, 45, 10]

import matplotlib.pyplot as plt
labels = 'Nokia', 'Samsung', 'Apple', 'Lumia'
values = [20, 30, 45, 10]
explode = [0.3, 0, 0, 0]
colors = ['yellow', 'green', 'red', 'blue']

figure = plt.figure(figsize=(5, 5), dpi=150, facecolor='#EEA9A9')
axes = figure.add_subplot(1, 1, 1)

axes.pie(values,labels=labels,explode=explode,colors=colors,autopct='%.1f%%',startangle=180,shadow={'ox': -0.01, 'oy': -0.01})
axes.set_title('Market Survey')
plt.show()

output

victor1629 commented 4 weeks ago
import matplotlib.pyplot as plt

labels = ['Nokia', 'Samsung', 'Apple', 'Lumia']
values = [20, 30, 45, 10]
colors = ['yellow', 'green', 'red', 'blue']
explode = (0.3, 0, 0, 0) 

plt.pie(values,
        labels=labels,
        colors=colors,
        autopct='%1.1f%%',
        startangle=185,
        explode=explode)  

plt.show()

image

import matplotlib.pyplot as plt

labels = ['Nokia', 'Samsung', 'Apple', 'Lumia']
values = [20, 30, 45, 10]
colors = ['yellow', 'green', 'red', 'blue']
explode = (0.3, 0, 0, 0)  

figure = plt.figure(figsize=(5,5),dpi=150,)
axes = figure.add_subplot(1,1,1)
axes.pie(values,
        labels=labels,
        colors=colors,
        autopct='%1.1f%%',
        startangle=180,
        explode=explode,
        shadow=True)

plt.show()

image

chiayuben commented 3 weeks ago
import matplotlib.pyplot as plt

labels = ['Nokia', 'Samsung', 'Apple', 'Lumia']
values = [20, 30, 45, 10]

#繪圖
plt.figure(figsize=(8,5),dpi=250,facecolor='#EEA9A9') #畫布
plt.pie(values,labels=labels,autopct='%1.1f%%', startangle=180,explode=(0.1,0,0,0),colors=['#FFFF00','g','r','b'],
wedgeprops = {'edgecolor': 'black','linewidth': 1})
plt.title('Pie Chart of Values by cell phone brand')

plt.show()

image

chihweihan commented 3 weeks ago
import matplotlib.pyplot as plt

labels = ['Nokia', 'Samsung', 'Apple', 'Lumia']
values = [20, 30, 45, 10]
explode = (0.4, 0, 0, 0)
color = ['yellow','green','red','blue']

figure = plt.figure(figsize=[5,5],dpi=250,facecolor='#81C7D4')
axes = figure.add_subplot(1, 1, 1)

axes.pie(values, explode=explode, labels=labels, colors=color, autopct='%1.1f%%',shadow=True, startangle=180, wedgeprops = {'edgecolor': 'black','linewidth': 1})
plt.show()

image