Changeset 9060:2a9a49c7f86b in orange


Ignore:
Timestamp:
10/05/11 14:49:39 (3 years ago)
Author:
anze <anze.staric@…>
Branch:
default
Convert:
1e3eb8ef9bc2ca509e01644af7b350366cf35a59
Message:

Improved biplot.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/projection/pca.py

    r8735 r9060  
    272272            plt.show() 
    273273             
    274     def biplot(self, filename = None, components = [1,2], title = 'Biplot'): 
     274    def biplot(self, filename = None, components = [0,1], title = 'Biplot'): 
    275275        """ 
    276276        Draw biplot for PCA. Actual projection must be performed via pca(data) 
     
    290290            raise orange.KernelException, 'Two components are needed for biplot' 
    291291         
    292         if not (1 <= min(components) <= max(components) <= len(self.eigen_values)): 
     292        if not (0 <= min(components) <= max(components) < len(self.eigen_values)): 
    293293            raise orange.KernelException, 'Invalid components' 
    294294         
     
    311311        ax1 = fig.add_subplot(111) 
    312312        ax1.set_title(title + "\n") 
    313         ax1.set_xlabel("PC%s (%d%%)" % (components[0], self.eigen_values[0] / self.variance_sum * 100)) 
    314         ax1.set_ylabel("PC%s (%d%%)" % (components[1], self.eigen_values[1] / self.variance_sum * 100)) 
     313        ax1.set_xlabel("PC%s (%d%%)" % (components[0], self.eigen_values[components[0]] / self.variance_sum * 100)) 
     314        ax1.set_ylabel("PC%s (%d%%)" % (components[1], self.eigen_values[components[1]] / self.variance_sum * 100)) 
    315315        ax1.xaxis.set_label_position('bottom') 
    316316        ax1.xaxis.set_ticks_position('bottom') 
     
    354354 
    355355        for (x, y, a) in zip(vectorsX, vectorsY,self.input_domain.attributes): 
    356             ax1.annotate('', (x, y), (0, 0), arrowprops = arrowprops) 
    357             ax1.text(x * 1.1, y * 1.2, a.name, color = 'red') 
     356            if max(x, y) < 0.1: 
     357                continue 
     358            print x, y, a 
     359            ax2.annotate('', (x, y), (0, 0), arrowprops = arrowprops) 
     360            ax2.text(x * 1.1, y * 1.2, a.name, color = 'red') 
    358361             
    359362        ax2.set_xlim(-max_load_value, max_load_value) 
Note: See TracChangeset for help on using the changeset viewer.