Hướng dẫn python code for multiple pie chart - mã python cho nhiều biểu đồ hình tròn

Tôi đang cố gắng hiển thị hai biểu đồ cùng một lúc bằng cách sử dụng matplotlib.

Nhưng tôi phải đóng một biểu đồ sau đó chỉ tôi có thể xem biểu đồ khác. Dù sao thì có cách nào để hiển thị cả biểu đồ hoặc nhiều số đồ thị cùng một lúc.

Đây là mã của tôi

num_pass=np.size[data[0::,1].astype[np.float]]
num_survive=np.sum[data[0::,1].astype[np.float]]
prop=num_survive/num_pass
num_dead=num_pass-num_survive
#print num_dead


labels='Dead','Survived'
sizes=[num_dead,num_survive]
colors=['darkorange','green']
mp.axis['equal']
mp.title['Titanic Survival Chart']
mp.pie[sizes, explode=[0.02,0], labels=labels,colors=colors,autopct='%1.1f%%', shadow=True, startangle=90]
mp.show[]

women_only_stats = data[0::,4] == "female" 
men_only_stats = data[0::,4] != "female" 

# Using the index from above we select the females and males separately
women_onboard = data[women_only_stats,1].astype[np.float]     
men_onboard = data[men_only_stats,1].astype[np.float]

labels='Men','Women'
sizes=[np.sum[women_onboard],np.sum[men_onboard]]
colors=['purple','red']
mp.axis['equal']
mp.title['People on board']
mp.pie[sizes, explode=[0.01,0], labels=labels,colors=colors,autopct='%1.1f%%', shadow=True, startangle=90]
mp.show[]

Làm thế nào tôi có thể hiển thị cả hai biểu đồ cùng một lúc?

    
  

Sử dụng hàm PIE [] để tạo biểu đồ hình tròn ..

  • Để hiển thị hình, sử dụng phương thức show [] ..
  • Bạn có thể vẽ nhiều biểu đồ trong Python không?
  • Các nhãn khu vực được cấu hình với nền màu vàng nhạt và đường viền đen. Đây là bằng cách lấy đối tượng TextBox đại diện cho nguyên mẫu nhãn khu vực bằng piechart.setlabelstyle, sau đó gọi phương thức hộp.setBackground của nó.
  • Các nhãn khu vực được di chuyển bên trong chiếc bánh bằng cách sử dụng piechart.setlabellayout với vị trí nhãn âm.

Sử dụng hàm PIE [] để tạo biểu đồ hình tròn ..

#!/usr/bin/python # The ChartDirector for Python module is assumed to be in "../lib" import sys, os sys.path.insert[0, os.path.join[os.path.abspath[sys.path[0]], "..", "lib"]] from pychartdir import * def createChart[chartIndex] : # The data for the pie chart data0 = [25, 18, 15] data1 = [14, 32, 24] data2 = [25, 23, 9] # The labels for the pie chart labels = ["Software", "Hardware", "Services"] # Create a PieChart object of size 180 x 160 pixels c = PieChart[180, 160] # Set the center of the pie at [90, 80] and the radius to 60 pixels c.setPieSize[90, 80, 60] # Set the border color of the sectors to white [ffffff] c.setLineColor[0xffffff] # Set the background color of the sector label to pale yellow [ffffc0] with a black border # [000000] c.setLabelStyle[].setBackground[0xffffc0, 0x000000] # Set the label to be slightly inside the perimeter of the circle c.setLabelLayout[CircleLayout, -10] # Set the title, data and colors according to which pie to draw if chartIndex == 0 : c.addTitle["Alpha Division", "Arial Bold", 8] c.setData[data0, labels] colors0 = [0xff3333, 0xff9999, 0xffcccc] c.setColors2[DataColor, colors0] elif chartIndex == 1 : c.addTitle["Beta Division", "Arial Bold", 8] c.setData[data1, labels] colors1 = [0x33ff33, 0x99ff99, 0xccffcc] c.setColors2[DataColor, colors1] else : c.addTitle["Gamma Division", "Arial Bold", 8] c.setData[data2, labels] colors2 = [0x3333ff, 0x9999ff, 0xccccff] c.setColors2[DataColor, colors2] # Output the chart c.makeChart["multipie%s.png" % chartIndex] createChart[0] createChart[1] createChart[2]

Sử dụng hàm PIE [] để tạo biểu đồ hình tròn ..

Sử dụng hàm PIE [] để tạo biểu đồ hình tròn ..

Để hiển thị hình, sử dụng phương thức show [] ..

Bạn có thể vẽ nhiều biểu đồ trong Python không?

  • Chúng ta có thể làm điều này bằng cách sử dụng Thư viện Python Matplotlib. Có hai cách hiệu quả để vẽ nhiều biểu đồ trong một ô duy nhất bằng cách sử dụng thư viện matplotlib. Sử dụng hàm Subplot [] của thư viện matplotlib. Tuỗi một biểu đồ sang biểu đồ khác sẽ giúp chúng tôi trực quan hóa cả biểu đồ trong một biểu đồ.
  • Xem thảo luận
  • Sử dụng hàm PIE [] để tạo biểu đồ hình tròn ..

    Để hiển thị hình, sử dụng phương thức show [] ..

    Bạn có thể vẽ nhiều biểu đồ trong Python không?

    Chúng ta có thể làm điều này bằng cách sử dụng Thư viện Python Matplotlib. Có hai cách hiệu quả để vẽ nhiều biểu đồ trong một ô duy nhất bằng cách sử dụng thư viện matplotlib. Sử dụng hàm Subplot [] của thư viện matplotlib. Tuỗi một biểu đồ sang biểu đồ khác sẽ giúp chúng tôi trực quan hóa cả biểu đồ trong một biểu đồ.Pie Chart is a circular statistical plot that can display only one series of data. The area of the chart is the total percentage of the given data. The area of slices of the pie represents the percentage of the parts of the data. The slices of pie are called wedges. The area of the wedge is determined by the length of the arc of the wedge. The area of a wedge represents the relative percentage of that part with respect to whole data. Pie charts are commonly used in business presentations like sales, operations, survey results, resources, etc as they provide a quick summary.
     

    Xem thảo luận

    Cải thiện bài viết
     

    Lưu bài viết matplotlib.pyplot.pie[data, explode=None, labels=None, colors=None, autopct=None, shadow=False]
    Parameters: 
    data represents the array of data values to be plotted, the fractional area of each slice is represented by data/sum[data]. If sum[data] Nhóm> Nhóm.Tất cả các biểu đồ hình tròn hiện được kết hợp như một con số.Họ sẽ di chuyển và thay đổi kích thước như một hình ảnh. Click Format > Group > Group. All pie charts are now combined as one figure. They will move and resize as one image.

    Làm thế nào để bạn tạo ra một biểu đồ hình tròn lồng nhau trong Python?

    Matplotlib với Python..
    Đặt kích thước hình và điều chỉnh phần đệm giữa và xung quanh các ô phụ ..
    Tạo một con số và một tập hợp các ô con ..
    Khởi tạo kích thước thay đổi, tạo Vals, CMAP, Outer_Colors, Dữ liệu bên trong_colors bằng cách sử dụng Numpy ..
    Sử dụng hàm PIE [] để tạo biểu đồ hình tròn ..
    Để hiển thị hình, sử dụng phương thức show [] ..

    Bạn có thể vẽ nhiều biểu đồ trong Python không?

    Chúng ta có thể làm điều này bằng cách sử dụng Thư viện Python Matplotlib.Có hai cách hiệu quả để vẽ nhiều biểu đồ trong một ô duy nhất bằng cách sử dụng thư viện matplotlib.Sử dụng hàm Subplot [] của thư viện matplotlib.Tuỗi một biểu đồ sang biểu đồ khác sẽ giúp chúng tôi trực quan hóa cả biểu đồ trong một biểu đồ.using the matplotlib python library. There are two effective ways to plot multiple graphs in a single plot by using the matplotlib library. Using subplot[] function of Matplotlib library. Superimposing one graph to another graph will help us visualize both the graph in a single plot.

    Bài Viết Liên Quan

    Chủ Đề