Changeset 8626:287f2d62c85f in orange


Ignore:
Timestamp:
08/07/11 12:26:16 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
61111cc0c6421b965efec2dd62743e0f8e791163
Message:

Add more documentation for the plot module

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/plot/owcurve.py

    r8613 r8626  
    1010    .. method:: attach(plot) 
    1111     
     12        Attaches this item to ``plot``.  
     13     
    1214        :param plot: the plot to which to add this item 
    1315        :type plot: :obj:`.OWPlot` 
     16         
     17        :seealso: :meth:`.OWPlot.add_item`.  
    1418         
    1519    .. method:: detach() 
     
    2529        :param rect: The new bounding rectangle in data coordinates 
    2630        :type rect: :obj:`.QRectF` 
    27          
     31 
    2832.. autoclass:: OWCurve 
    2933    :members: 
     
    4145}) 
    4246class OWCurve(orangeplot.Curve): 
     47    """  
     48        This class represents a curve on a plot. 
     49         
     50       :param xData: list of x coordinates 
     51       :type xData: list of float 
     52        
     53       :param yData: list of y coordinates 
     54       :type yData: list of float 
     55        
     56       :param x_axis_key: The x axis of this curve 
     57       :type x_axis_key: int 
     58        
     59       :param y_axis_key: The y axis of this curve 
     60       :type y_axis_key: int 
     61        
     62       :param tooltip: The curve's tooltip 
     63       :type tooltip: str 
     64         
     65        .. method:: point_item(x, y, size=0, parent=None) 
     66         
     67            Returns a single point with this curve's properties.  
     68            It is useful for representing the curve, for example in the legend. 
     69             
     70            :param x: The x coordinate of the point. 
     71            :type x: float 
     72             
     73            :param y: The y coordinate of the point. 
     74            :type y: float 
     75             
     76            :param size: If nonzero, this argument determines the size of the resulting point. Otherwise, the point is created with the curve's :meth:`OWCurve.point_size` 
     77            :type size: int 
     78                          
     79            :param parent: An optional parent for the returned item. 
     80            :type parent: :obj:`.QGraphicsItem` 
     81             
     82        .. attribute:: name 
     83            :type: str 
     84 
     85            The name of the curve, used in the legend or in tooltips 
     86             
     87        .. method:: update_properties() 
     88         
     89            Called by the plot, this function updates the curve's internal state to match its settings.  
     90             
     91            The default implementation moves creates the points and sets their position, size, shape and color.  
     92             
     93        .. method:: set_data(x_data, y_data) 
     94         
     95            Sets the curve's data to a list of coordinates specified by ``x_data`` and ``y_data``.  
     96             
     97        .. method:: data() 
     98             
     99            :returns: The curve's data as a list of data points. 
     100            :rtype: list of tuple of float float 
    43101    """ 
    44         This class represents a curve on a plot. 
    45     """ 
    46     def __init__(self, xData=[], yData=[], x_axis_key=xBottom, y_axis_key=yLeft, tooltip=None, parent=None, scene=None): 
    47         orangeplot.Curve.__init__(self, xData, yData, parent, scene) 
     102    def __init__(self, xData=[], yData=[], x_axis_key=xBottom, y_axis_key=yLeft, tooltip=None): 
     103        orangeplot.Curve.__init__(self, xData, yData) 
    48104        self.set_axes(x_axis_key, y_axis_key) 
    49105        if tooltip: 
  • orange/OrangeWidgets/plot/owplot.py

    r8619 r8626  
    104104        .. automethod:: inv_transform 
    105105         
     106        .. method:: nearest_point(pos) 
     107         
     108            Returns the point nearest to ``pos``, or ``None`` if no point is close enough.  
     109             
     110            :param pos: The position in scene coordinates 
     111            :type pos: QPointF 
     112             
     113            :rtype: :obj:`.OWPoint` 
     114             
     115        .. method:: point_at(pos) 
     116         
     117            If there is a point with data coordinates equal to ``pos``, if is returned.  
     118            Otherwise, this function returns None.  
     119         
     120            :param pos: The position in data coordinates 
     121            :type pos: tuple of float float 
     122             
     123            :rtype: :obj:`.OWPoint` 
     124         
    106125         
    107126    **Data curves** 
     
    114133        .. automethod:: add_marker 
    115134         
    116         .. method:: add_item 
    117          
    118             Adds any PlotItem to this plot 
     135        .. method:: add_item(item) 
     136         
     137            Adds any PlotItem ``item`` to this plot.  
     138            Calling this function directly is useful for adding a :obj:`.Marker` or another object that does not have to appear in the legend.  
     139            For data curves, consider using :meth:`add_custom_curve` instead.  
     140             
     141        .. method:: plot_items() 
     142         
     143            Returns the list of all plot items added to this graph with :meth:`add_item` or :meth:`.PlotItem.attach`.  
    119144             
    120145    **Axes** 
     
    129154         
    130155        .. automethod:: set_axis_scale 
     156         
     157    **Settings** 
     158     
     159    .. attribute:: gui 
     160     
     161            An :obj:`.OWPlotGUI` object associated with this graph 
     162             
     163    **Point Selection and Marking** 
     164     
     165        There are four possible selection behaviors used for selecting or marking points in OWPlot.  
     166        They are used in :meth:`select_points` and :meth:`mark_points` and are the same for both operations.  
     167     
     168        .. data:: AddSelection 
     169             
     170            The points are added to the selection, without affected the currently selected points 
     171             
     172        .. data:: RemoveSelection 
     173     
     174            The points are removed from the selection, without affected the currently selected points 
     175             
     176        .. data:: ToggleSelection 
     177         
     178            The points' selection state is toggled 
     179             
     180        .. data:: ReplaceSelection 
     181         
     182            The current selection is replaced with the new one 
     183             
     184        .. note:: There are exacly the same functions for point selection and marking.  
     185                For simplicity, they are only documented once.   
     186 
     187        .. method:: select_points(area, behavior) 
     188        .. method:: mark_points(area, behavior) 
     189         
     190            Selects or marks all points inside the ``area`` 
     191         
     192            :param area: The newly selected/marked area 
     193            :type area: QRectF or QPolygonF 
     194             
     195            :param behavior: :data:`AddSelection`, :data:`RemoveSelection`, :data:`ToggleSelection` or :data:`ReplaceSelection`  
     196            :type behavior: int 
     197             
     198        .. method:: unselect_all_points() 
     199        .. method:: unmark_all_points() 
     200         
     201            Unselects or unmarks all the points in the plot 
     202             
     203        .. method:: selected_points() 
     204        .. method:: marked_points() 
     205         
     206            Returns a list of all selected or marked points 
     207             
     208            :rtype: list of OWPoint 
     209             
     210        .. method:: selected_points(xData, yData) 
     211         
     212            For each of the point specified by ``xData`` and ``yData``, the point's selection state is returned.  
     213             
     214            :param xData: The list of x coordinates 
     215            :type xData: list of float 
     216             
     217            :param yData: The list of y coordinates 
     218            :type yData: list of float 
     219             
     220            :rtype: list of int 
     221             
     222         
    131223     
    132224    """ 
     
    229321         
    230322        self.gui = OWPlotGUI(self) 
    231  
     323    """ 
     324            An :obj:`.OWPlotGUI` object associated with this plot 
     325    """ 
    232326        self.activate_zooming() 
    233327        self.selection_behavior = self.AddSelection 
     
    261355            to scene coordinates.  
    262356             
    263             If ``zoom`` is ``True``, the point is additionally transformed with :attr:`zoom_transform` 
     357            :param point: The point in data coordinates 
     358            :type point: tuple or QPointF 
     359             
     360            :param axes: The pair of axes along which to transform the point. If none are specified, (xBottom, yLeft) will be used.  
     361            :type axes: tuple of float float 
     362             
     363            :param zoom: if ``True``, the current :attr:`zoom_transform` will be considered in the transformation. 
     364            :type zoom: int 
     365             
     366            :return: The transformed point in scene coordinates 
     367            :type: tuple of float float 
    264368        ''' 
    265369        if type(point) == tuple: 
     
    277381    def map_from_graph(self, point, axes = None, zoom = False): 
    278382        ''' 
    279             Maps ``point``, which can be ether a tuple of (x,y), a QPoint or a QPointF, from scene coordinates 
    280             to data coordinates.  
    281              
    282             If ``zoom`` is ``True``, the point is additionally transformed with :attr:`zoom_transform` 
     383            Maps ``point``, which can be ether a tuple of (x,y), a QPoint or a QPointF, from data coordinates 
     384            to scene coordinates.  
     385             
     386            :param point: The point in data coordinates 
     387            :type point: tuple or QPointF 
     388             
     389            :param axes: The pair of axes along which to transform the point. If none are specified, (xBottom, yLeft) will be used.  
     390            :type axes: tuple of float float 
     391             
     392            :param zoom: if ``True``, the current :attr:`zoom_transform` will be considered in the transformation. 
     393            :type zoom: int 
     394             
     395            :returns: The transformed point in data coordinates 
     396            :rtype: tuple of float float 
    283397        ''' 
    284398        if type(point) == tuple: 
     
    10171131         
    10181132    def transform(self, axis_id, value): 
     1133        """ 
     1134            Transforms the ``value`` from data to scene coordinates along the axis ``axis_id``.  
     1135             
     1136            This function always ignores zoom. If you need to account for zooming, use :meth:`map_to_graph`.  
     1137        """ 
    10191138        if axis_id in XAxes: 
    10201139            size = self.graph_area.width() 
     
    10301149         
    10311150    def inv_transform(self, axis_id, value): 
     1151        """ 
     1152            Transforms the ``value`` from scene to data coordinates along the axis ``axis_id``.  
     1153             
     1154            This function always ignores zoom. If you need to account for zooming, use :meth:`map_from_graph`.  
     1155        """ 
    10321156        if axis_id in XAxes: 
    10331157            size = self.graph_area.width() 
  • orange/OrangeWidgets/plot/owplotgui.py

    r8550 r8626  
    66GUI elements for plots (``owplotgui``) 
    77###################################### 
     8 
     9This module contains functions and classes for creating GUI elements commonly used for plots.  
    810 
    911.. autoclass:: OrientedWidget 
     
    142144        :param plot: The object whose attributes will be modified 
    143145        :type plot: :obj:`.OWPlot` 
    144          
    145         :param attr_name: Name of attribute which will be set when the button is clicked.  
    146                           If this parameter is empty or None, no attribute will be set.  
    147         :type attr_name: str 
    148          
    149         :param attr_value: The value that will be assigned to the ``attr_name`` when the button is clicked.  
    150         :type attr: any 
    151          
    152         :param callback: Function to be called when the button is clicked.  
    153                          If a string is passed as ``callback``, a method by that name of ``plot`` will be called.  
    154                          If this parameter is empty or None, no function will be called 
    155         :type callback: str or function 
    156146    ''' 
    157147    def __init__(self, plot, attr_name, attr_value, callback, parent): 
     
    182172        for configuration and interaction with the ``plot``.  
    183173         
    184         It provides shorter version of some methods in :obj:`.OWGUI` that are directly related to an :obj:`.OWPlot` object.  
     174        It provides shorter versions of some methods in :obj:`.OWGUI` that are directly related to an :obj:`.OWPlot` object.  
     175         
     176        Normally, you don't have to construct this class manually. Instead, first create the plot,  
     177        then use the :attr:`.OWPlot.gui` attribute.  
     178         
     179        Most methods in this class have similar arguments, so they are explaned here in a single place.  
     180         
     181        :param widget: The parent widget which will contain the newly created widget.  
     182        :type widget: QWidget 
     183         
     184        :param id: If ``id`` is an ``int``, a button is constructed from the default table.  
     185                   Otherwise, ``id`` must be tuple with 5 or 6 elements. These elements 
     186                   are explained in the next table.  
     187        :type id: int or tuple 
     188         
     189        :param ids: A list of widget identifiers 
     190        :type ids: list of id 
     191         
     192        :param text: The text displayed on the widget 
     193        :type text: str 
     194         
     195        When using widgets that are specific to your visualization and not included here, you have to provide your 
     196        own widgets id's. They are a tuple with the following members: 
     197         
     198        :param id: An optional unique identifier for the widget.  
     199                   This is only needed if you want to retrive this widget using :obj:`.OWToolbar.buttons`.  
     200        :type id: int or str 
     201         
     202        :param text: The text to be displayed on or next to the widget 
     203        :type text: str 
     204         
     205        :param attr_name: Name of attribute which will be set when the button is clicked.  
     206                          If this widget is checkable, its check state will be set 
     207                          according to the current value of this attribute.  
     208                          If this parameter is empty or None, no attribute will be read or set.  
     209        :type attr_name: str 
     210         
     211        :param attr_value: The value that will be assigned to the ``attr_name`` when the button is clicked.  
     212        :type attr: any 
     213         
     214        :param callback: Function to be called when the button is clicked.  
     215                         If a string is passed as ``callback``, a method by that name of ``plot`` will be called.  
     216                         If this parameter is empty or ``None``, no function will be called 
     217        :type callback: str or function 
     218         
     219        :param icon_name: The filename of the icon for this widget, without the '.png' suffix.  
     220        :type icon_name: str 
     221         
    185222    ''' 
    186223    def __init__(self, plot): 
     
    356393        ''' 
    357394            Creates an :obj:`.OWButton` and adds it to the parent ``widget``.  
    358              
    359             :param id: If ``id`` is an ``int``, a button is constructed from the default table.  
    360                        Otherwise, ``id`` must be tuple of size 4 or 5 with members. The first is optional and  
    361                        is a unique identifier for the button, the second is its name, 
    362                        the next three are the ``attr_name``, ``attr_value`` and ``callback`` arguments to :obj:`.OWButton`,  
    363                        and the last one is the icon name 
    364             :type if: int or tuple 
    365              
    366             :param widget: The button's parent widget 
    367             :type widget: QWidget 
    368395        ''' 
    369396        if type(id) == int: 
     
    407434        t.buttons[self.Select].click() 
    408435        t.buttons[self.SelectionOne].click() 
    409         return t 
    410      
     436        return t     
  • source/orangeplot/plot.cpp

    r8613 r8626  
    238238} 
    239239 
    240 QList< int > Plot::selected_points(const QList< double > x_data, const QList< double > y_data, const QTransform& transform) 
     240QList< int > Plot::selected_points(const QList< double > x_data, const QList< double > y_data) 
    241241{ 
    242242    Q_ASSERT(x_data.size() == y_data.size()); 
  • source/orangeplot/plot.h

    r8612 r8626  
    5656     * created the points 
    5757     **/ 
    58     QList< int > selected_points(const QList< double > x_data, const QList< double > y_data, const QTransform& transform); 
     58    QList< int > selected_points(const QList< double > x_data, const QList< double > y_data); 
    5959    QList< Point*> selected_points(); 
    6060     
  • source/orangeplot/plot.sip

    r8612 r8626  
    6767    void unmark_all_points(); 
    6868     
    69     QList< int > selected_points(const QList< double > x_data, const QList< double > y_data, const QTransform& transform); 
     69    QList< int > selected_points(const QList< double > x_data, const QList< double > y_data); 
    7070    QList< Point* > selected_points(); 
    7171    Point* nearest_point(const QPointF& pos); 
Note: See TracChangeset for help on using the changeset viewer.