Changeset 8238:b3959453dc82 in orange


Ignore:
Timestamp:
08/20/11 09:40:06 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
30e44aa1eab2c9647987b1b6a509b1770c6c723d
Message:

Start work on a simple example plot widget for documentation.

Location:
orange/doc/widgets
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • orange/doc/widgets/owplot_example.py

    r8190 r8238  
    55from OWWidget import * 
    66import OWGUI 
     7from plot.owplot import * 
    78 
    8 class ExampleWidget(OWWidget): 
     9class BasicPlot(OWPlot): 
     10    pass 
     11 
     12class BasicWidget(OWWidget): 
    913    def __init__(self, parent=None, signalManager=None): 
    10         OWWidget.__init__(self, parent, signalManager, 'Example') 
    11             self.inputs = [("Train Data", ExampleTable, self.trainset), ("Test Data", ExampleTable, self.testset, 1, 1), ("Learner", orange.Learner, self.learner, 0)] 
    12      
     14        OWWidget.__init__(self, parent, signalManager, 'Basic') 
     15        self.inputs = [("Examples", ExampleTable, self.set_data)] 
     16         
     17        self.plot = BasicPlot(self, self.mainArea, "Example plot") 
     18             
     19    def set_data(self, data):         
     20        if data is not None and (len(data) == 0 or len(data.domain) == 0): 
     21            data = None 
     22             
     23        self.data = data 
     24        n = len(data) # The number of attributes in data 
     25         
     26        x_index = 0 
     27        y_index = 1 if n > 1 else 0 
     28         
     29        if data.domain[x_index].varType = Orange.VarType.Discrete: 
     30            self.plot.set_axis_labels(OWPlot.xBottom, get_variable_names_sorted(self.data.domain[x_index])) 
     31        if data.domain[y_index].varType = Orange.VarType.Discrete: 
     32            self.plot.set_axis_labels(OWPlot.yLeft, get_variable_names_sorted(self.data.domain[y_index])) 
     33             
     34        color_data = data[2] if n > 2 else [self.plot.color(OWPalette.Data)] 
     35        size = data[3] if n > 3 else [10] 
     36         
     37        self.plot.set_main_curve_data() 
     38         
  • orange/doc/widgets/plots.htm

    r8211 r8238  
    1414interface. This method is described in <a href="graphics.htm">Graphing</a>. </p> 
    1515 
    16 <p>Howere, Orange provides a new plotting interface via the <code>OrangeWidgets.plot</code> 
     16<p>However, Orange provides a new plotting interface via the <code>OrangeWidgets.plot</code> 
    1717module. The OWPlot class use Qt's graphics framework and was written specifically for 
    1818Orange, so it contains methods more suitable to its data structures. It also provides 
Note: See TracChangeset for help on using the changeset viewer.