def crear_grafica(self, grafica=None): if not grafica: grafica = self.grafica self.grafica = grafica pasar = False #self.cargar_colores() if self.colores and type(self.colores[-1]) == float: c1 = self.colores[-3] c2 = self.colores[-2] c3 = self.colores[-1] self.colores.remove(self.colores[-1]) self.colores.remove(self.colores[-1]) self.colores.remove(self.colores[-1]) self.colores.insert(-1, (c1, c2, c3)) for x in self.valores.keys(): for i in self.valores[x]: if i >= 1: pasar = True break if not pasar and self.valores.keys(): self.valores[sorted(self.valores.keys())[0]] = [1] if grafica == 'Gráfica de barras horizontales': y_labels = sorted(self.valores.keys()) y_labels.sort() if self.valores: if len(self.valores[sorted(self.valores.keys())[0]]) == 1: valores = self.transformar_a_barras() else: valores = self.valores CairoPlot.horizontal_bar_plot( self.direccion, valores, self.tamanyo_x, self.tamanyo_y, background=self.fondo, border=self.borde, display_values=self.display_values, grid=self.cuadricula, rounded_corners=self.rounded_corners, stack=False, three_dimension=True, series_labels=None, x_labels=[], y_labels=y_labels, x_bounds=None, y_bounds=None, colors=self.colores) elif grafica == 'Gráfica de barras verticales': x_labels = sorted(self.valores.keys()) #self.l_valores y_labels = [] x_labels.sort() if self.valores: if len(self.valores[sorted(self.valores.keys())[0]]) == 1: valores = self.transformar_a_barras() else: valores = self.valores CairoPlot.vertical_bar_plot( self.direccion, valores, self.tamanyo_x, self.tamanyo_y, background=self.fondo, border=self.borde, display_values=self.display_values, grid=self.cuadricula, rounded_corners=self.rounded_corners, stack=False, three_dimension=True, series_labels=None, x_labels=x_labels, y_labels=y_labels, x_bounds=None, y_bounds=None, colors=self.colores) elif grafica == 'Gráfica de torta': CairoPlot.pie_plot( self.direccion, self.valores, self.tamanyo_x, self.tamanyo_y, background=self.fondo, gradient=True, shadow=False, colors=self.colores) elif grafica == 'Gráfica de puntos': CairoPlot.dot_line_plot( self.direccion, self.valores, self.tamanyo_x, self.tamanyo_y, background=self.fondo, border=self.borde, axis=self.axis, dots=False, grid=self.cuadricula, series_legend=self.grupos, x_labels=self.x_labels, y_labels=self.y_labels, x_bounds=None, y_bounds=None, x_title=self.titulo_x, y_title=self.titulo_y, series_colors=self.colores) elif grafica == 'Gráfica de anillo': CairoPlot.donut_plot( self.direccion, self.valores, self.tamanyo_x, self.tamanyo_y, background=self.fondo, gradient=True, shadow=False, colors=self.colores, inner_radius=self.inner_radius) elif grafica == 'Gráfica de ecuaciones': valores, rectas = self.transformar_a_ecuaciones() CairoPlot.dot_ecuations_plot(self.direccion, valores, rectas=rectas, width=self.tamanyo_x, height=self.tamanyo_y) self.area.set_plot(self.direccion) self.emit('save-changes')
if name == "Unincorporated Gilpin County": name = "Uninc. Gilpin County" else: pass if name == "Unincorporated Jefferson County": name = "Uninc. Jefferson County" else: pass series_labels = [name, "Region"] colors = ["light_blue", "Navy" ] data = [[other, reg_other], [wttw, reg_wttw], [bus, reg_bus], [man, reg_man], [perserv, reg_perserv], [ps, reg_ps], [pa, reg_pa], [retail, reg_retail], [uc, reg_uc], [exa, reg_exa]] #x_labels = [ "line1", "line2", "line3", "line4", "line5", "line6" ] #background = (1.0,0.0,1.0,1.0) y_labels = [ "Other", "Wholesale Trade", "Business Services", "Manufacturing", "Personal Services", "Professional Services", "Public Administration", "Retail Trade", "Utilities & Construction", "Extractive Activities" ] CairoPlot.horizontal_bar_plot ( '/home/michael/Documents/comm_prof/emp_by_ind/'+name+'.pdf', data, 380, 230, background = "white",border = 20, display_values = True, grid = False, y_labels = y_labels, series_labels = series_labels, colors = colors, value_formatter = lambda x: makepercent_nodata(x)) #series_labels = series_labels #value_formatter = lambda x: addcomma(x) #'smb://cognet%2Fmtafel@kennedy/crs/Community%20Profiles_2010_2011/charts/hh_type'+name+'hh_type.png' # '/home/michael/Documents/comm_prof/hh_type/' #x_labels = x_labels # plt.savefig("/home/michael/Pictures/"+name+"_household.png")