Пример #1
0
	def update_color_in_projection(self,resultDict = None, ax = None, export = False):
		'''
		Projection plot in dimensional reduction show feature names and can
		be colored occording to groups. (For example if feature == name of experiment
		where expresison values of several proteins/genes have been measured (e.g Tutorial Data 2)
		'''
		if resultDict is None:
			resultDict =  self.plotter.dimRedResults
		
		if 'color' in resultDict:
			colorDict = resultDict['color']
			groupDict = resultDict['group']	 
			featureOrder = self.plotter.dimRedResults['data']['Components'].T.index
			colors = [colorDict[feature] for feature in featureOrder]
			groups = [groupDict[feature] for feature in featureOrder]
			uniqueValuesDict = OrderedDict((comb,True) for comb in list(zip(colors,groups)))
			colorsUnique,groupsUnique = zip(*list(uniqueValuesDict.keys()))
			if ax is None:
				ax = self.axisDict[1]
			ax.collections[0].set_facecolor(colors)
			axisStyler(ax,forceLegend = True ,kwsLegend = {'addPatches':True,
 									   		'legendItems' : list(groupsUnique),
 									   		'colorMap' : list(colorsUnique),
 									   		'leg_title':'Grouping',
 									   		 'patchKws':{'alpha':self.scatStyle['alpha'],
 									   		 'lw':0.5}})
			if export == False:
				self.axisDict[3].collections[0].set_facecolor(colors)	
Пример #2
0
    def add_legend(self, ax, export=False):
        '''
		Adds a legend to a plot displaying the different categorical values. 
		'''
        if export == False:
            self.clean_up_old_legend_lines()

        leg = ax.get_legend()
        if leg is not None:
            leg.remove()
        categoricalColumn = self.sizeStatsAndColorChanges[
            'change_color_by_categorical_columns']
        for level, color in self.colorMapDict.items():
            if str(level) not in ['nan', ' ']:
                # generate and save line that is used for legend
                collectionLegend = ax.plot([], [],
                                           color=color,
                                           linewidth=0.8,
                                           label=level)
                if export == False:
                    self.savedLegendLines.append(collectionLegend)

        legendTitle = get_elements_from_list_as_string(
            categoricalColumn, addString='Categorical Levels: ', newLine=True)

        axisStyler(ax, forceLegend=True, kwsLegend={'leg_title': legendTitle})
Пример #3
0
	def style_axis(self, specificAxis = None, id = None):
		'''
		Style axis.
		'''
		if specificAxis is None:
			for n, ax in self.axisDict.items():
				xLabel, yLabel = self.get_axisLabels(n)
				axisStyler(ax,ylabel = yLabel, xlabel = xLabel)
		else:
			xLabel, yLabel = self.get_axisLabels(id)
			axisStyler(specificAxis,ylabel = yLabel, xlabel = xLabel)
    def style_axis(self, ax=None):
        '''
		Style axis.
		'''
        if ax is None:
            ax = self.axisDict[0]

        axisStyler(ax,
                   forceLegend=True,
                   kwsLegend=dict(leg_title='Counts', ncols=3),
                   nTicksOnYAxis=5,
                   nTicksOnXAxis=5)
Пример #5
0
	def style_axis(self, specificAxis = None):
		'''
		Change style of axis. 
		'''
		if specificAxis is None:
			ax = self.axisDict[0]
		else:
			ax = specificAxis
		
		ax.set_xticks(range(len(self.numericColumns)))
		ax.set_xticklabels(self.numericColumns)
		axisStyler(ax=ax, ylabel = 'Value',nTicksOnYAxis = 4,rotationXTicks = 90,
			newXLim = (-0.2,len(self.numericColumns)-0.8), newYLim=(self.yMin ,self.yMax))