Container for the artists of pie charts (e.g. created by `.Axes.pie`). .. versionadded:: 3.11 .. warning:: The class name ``PieContainer`` name is provisional and may change in future to reflect development of its functionality. You can access the wedge patches an
| 149 | |
| 150 | |
| 151 | class PieContainer: |
| 152 | """ |
| 153 | Container for the artists of pie charts (e.g. created by `.Axes.pie`). |
| 154 | |
| 155 | .. versionadded:: 3.11 |
| 156 | |
| 157 | .. warning:: |
| 158 | The class name ``PieContainer`` name is provisional and may change in future |
| 159 | to reflect development of its functionality. |
| 160 | |
| 161 | You can access the wedge patches and further parameters by the attributes. |
| 162 | |
| 163 | Attributes |
| 164 | ---------- |
| 165 | wedges : list of `~matplotlib.patches.Wedge` |
| 166 | The artists of the pie wedges. |
| 167 | |
| 168 | values : `numpy.ndarray` |
| 169 | The data that the pie is based on. |
| 170 | |
| 171 | fracs : `numpy.ndarray` |
| 172 | The fraction of the pie that each wedge represents. |
| 173 | |
| 174 | texts : list of list of `~matplotlib.text.Text` |
| 175 | The artists of any labels on the pie wedges. Each inner list has one |
| 176 | text label per wedge. |
| 177 | |
| 178 | """ |
| 179 | def __init__(self, wedges, values, normalize): |
| 180 | self.wedges = wedges |
| 181 | self._texts = [] |
| 182 | self._values = values |
| 183 | self._normalize = normalize |
| 184 | |
| 185 | @property |
| 186 | def texts(self): |
| 187 | # Only return non-empty sublists. An empty sublist may have been added |
| 188 | # for backwards compatibility of the Axes.pie return value (see __getitem__). |
| 189 | return [t_list for t_list in self._texts if t_list] |
| 190 | |
| 191 | @property |
| 192 | def values(self): |
| 193 | result = self._values.copy() |
| 194 | result.flags.writeable = False |
| 195 | return result |
| 196 | |
| 197 | @property |
| 198 | def fracs(self): |
| 199 | if self._normalize: |
| 200 | result = self._values / self._values.sum() |
| 201 | else: |
| 202 | result = self._values |
| 203 | |
| 204 | result.flags.writeable = False |
| 205 | return result |
| 206 | |
| 207 | def add_texts(self, texts): |
| 208 | """Add a list of `~matplotlib.text.Text` objects to the container.""" |
no outgoing calls
no test coverage detected
searching dependent graphs…