예제 #1
0
 def graph_pie(self, parts, autopct=None, labels=None, legend_labels=None):
     colors = color.get_scale(self.get_color('pie_low', ColorHexCode.BLACK),
                              self.get_color('pie_high', ColorHexCode.GRAY),
                              len(parts),
                              ascending=False)
     ax = self.axes[0]
     pie = ax.pie(
         parts,
         autopct=autopct,
         colors=colors,
         explode=[0.1] + ([0] * (len(parts) - 1)),
         labels=labels or tuple("{0:.1f}%".format(p) for p in parts),
         labeldistance=1.15,
         shadow=True,
         startangle=45,
         textprops={'color': self.get_color('fg', ColorHexCode.BLACK)},
         wedgeprops={'linewidth': 0})
     ax.axis('equal')
     if legend_labels is not None:
         self.add_legend_patch(tuple(zip(colors, legend_labels)),
                               fontsize='x-small')
     return pie
예제 #2
0
	def graph_pie(self, parts, autopct=None, labels=None, legend_labels=None):
		colors = color.get_scale(
			self.get_color('pie_low', ColorHexCode.BLACK),
			self.get_color('pie_high', ColorHexCode.GRAY),
			len(parts),
			ascending=False
		)
		ax = self.axes[0]
		pie = ax.pie(
			parts,
			autopct=autopct,
			colors=colors,
			explode=[0.1] + ([0] * (len(parts) - 1)),
			labels=labels or tuple("{0:{PERCENT}}%".format(p, PERCENT=PERCENT_FORMAT) for p in parts),
			labeldistance=1.15,
			shadow=True,
			startangle=45,
			textprops={'color': self.get_color('fg', ColorHexCode.BLACK)},
			wedgeprops={'linewidth': 0}
		)
		ax.axis('equal')
		if legend_labels is not None:
			self.add_legend_patch(tuple(zip(colors, legend_labels)), fontsize='x-small')
		return pie