current position:Home>Python pyecarts drawing pie chart

Python pyecarts drawing pie chart

2022-01-27 03:06:21 Listening to music and learning Python

 

One 、pyecharts Introduction to pie chart Syntax

Pie chart is mainly used to show the proportion of different categories of data in the total . The radian of each is not the proportion of data volume
pie.add() Method usage
add(name, attr, value,
radius=None,
center=None,
rosetype=None, **kwargs)
name->str legend title
attr->list The attribute name
value->list Value corresponding to property
radius->list The radius of the pie , The first item in the array is the inner radius , The second term is the outer radius , The default is [0,75]
The default setting is percentage , Relative to half of the smaller item in the height and width of the container
center-> The coordinates of the center of the pie chart , The first item in the array is the abscissa , The second is the ordinate , The default is [50,50]
The default setting is percentage , When set as a percentage, the first item is relative to the height of the container , The second item is also relative to the height of the container
rosetype->str
Is it shown as a nightingale map . Size data by radius , Yes radius and area Two modes . The default is radius
radius: The percentage of data presented by the sector center angle , Radius shows the size of the data
area: All sectors have the same center angle , Show data size by radius only

Two 、 Draw a normal pie chart

attr = [" shirt ", " Woolen sweater ", " Snow spins unlined upper garment ", " The trousers ", " High heels ", " socks "]
v1 = [11, 12, 13, 10, 10, 10]
pie1 = Pie(" Pie chart example ")
pie1.add("", attr, v1, is_label_show=True,center=[50,50])
page.add(pie1)

  3、 ... and 、 Draw a circle

attr = [" shirt ", " Woolen sweater ", " Snow spins unlined upper garment ", " The trousers ", " High heels ", " socks "]
v1 = [11, 12, 13, 10, 10, 10]
pie2 = Pie(" The pie chart - An example of a doughnut ", title_pos='center')
pie2.add(
    "",
    attr,
    v1,
    radius=[40, 75],
    label_text_color=None,
    is_label_show=True,
    legend_orient="vertical",
    legend_pos="left",
)
page.add(pie2)

   Four 、 Draw the pie chart - Rose chart

attr = [" shirt ", " Woolen sweater ", " Snow spins unlined upper garment ", " The trousers ", " High heels ", " socks "]
v1 = [11, 12, 13, 10, 10, 10]
v2 = [19, 21, 32, 20, 20, 33]
pie3 = Pie(" The pie chart - An example of a rose chart ")
pie3.add(
    " goods A",
    attr,
    v1,
    is_random=True,
    rosetype="radius",
    is_label_show=True,
)
page.add(pie3)

attr = [" shirt ", " Woolen sweater ", " Snow spins unlined upper garment ", " The trousers ", " High heels ", " socks "]
v1 = [11, 12, 13, 10, 10, 10]
v2 = [19, 21, 32, 20, 20, 33]
pie4 = Pie(" The pie chart - An example of a rose chart ")
pie4.add(
    " goods B",
    attr,
    v2,
    #center=[75, 50],
    is_random=True,
    #radius=[30, 75],
    rosetype="area",
    is_legend_show=True,
    is_label_show=True,
)
page.add(pie4)

 

 

copyright notice
author[Listening to music and learning Python],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270306174265.html

Random recommended