Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
x = xdescent + width / 2.0
y = ydescent + height / 2.0
kwargs = {
"horizontalalignment": "center",
"verticalalignment": "center",
"color": orig_handle.color,
"fontproperties": fm.FontProperties(fname=self.font_file, size=fontsize),
}
kwargs.update(orig_handle.kwargs)
annotation = Text(x, y, orig_handle.text, **kwargs)
return [annotation]
HANDLER_MAP = {
SolidTextLegend: TextLegendHandler(FONTAWESOME_FILES["solid"]),
RegularTextLegend: TextLegendHandler(FONTAWESOME_FILES["regular"]),
BrandsTextLegend: TextLegendHandler(FONTAWESOME_FILES["brands"]),
}
class Waffle(Figure):
"""
A custom Figure class to make waffle charts.
:param values: Numerical value of each category. If it is a dict, the keys would be used as labels.
:type values: list|dict|pandas.Series
:param rows: The number of lines of the waffle chart.
:type rows: int
:param columns: The number of columns of the waffle chart.
break
this_cat_block_count = 0
elif block_number_per_cat[class_index] < 0:
raise ValueError("Negative value is not acceptable")
if this_cat_block_count > colored_block_number_per_cat[class_index]:
color = (0, 0, 0, 0) # transparent
else:
color = self._pa["colors"][class_index]
x = x_full * col
y = y_full * row
if self._pa["icons"]:
prop.set_file(FONTAWESOME_FILES[self._pa["icon_style"][class_index]])
self.ax.text(
x=x, y=y, s=self._pa["icons"][class_index], color=color, fontproperties=prop,
)
elif self._pa["characters"]:
self.ax.text(
x=x, y=y, s=self._pa["characters"][class_index], color=color, fontproperties=prop,
)
else:
self.ax.add_artist(Rectangle(xy=(x, y), width=block_x_length, height=block_y_length, color=color))
block_index += 1
this_cat_block_count += 1
if block_index >= sum(block_number_per_cat[: class_index + 1]):
class_index += 1
if class_index > self.values_len - 1:
break