![]() Plt.pie(df, labels=df, autopct='%1.2f%%', explode=explode) If we want to pull away a sector from the radius, we can add an offset to each sector in the parameter explode. The following example shows how to use parameter explode. In the example, we pass the population and country name to pie(), and specify the format for displaying percentages. pie() will automatically add up all populations and calculate the percentage. Pie() is quite simple to use, let’s take a look at the following example. data: Data. If data is passed to the parameter data, the parameter x, explode, labels, and colors will be the column names of data.autopct: The format of the percentage in the block. The type is string.colors: The color of each block. The type is array-like.labels: The label of each block. The type is array-like.explode: The offset of each sector. The type is array-like.Please refer to the official website for other parameters. Matplotlib’s pie() allows us to draw a pie chart very easily. Its declaration is as follows.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |