Changeset 8547:fb975dde59ff in orange


Ignore:
Timestamp:
07/31/11 11:34:56 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
91ce6a705f9e4cc621160f2d61c2f86569f37362
Message:

Add more documentatin to the plot module

Location:
orange/OrangeWidgets/plot
Files:
3 edited

Legend:

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

    r8535 r8547  
    44############################## 
    55 
     6.. class:: orangeplot.PlotItem 
     7 
     8    This class represents a base for any item than can be added to a plot.  
     9     
     10    .. method:: attach(plot) 
     11     
     12        :param plot: the plot to which to add this item 
     13        :type plot: :obj:`.OWPlot` 
     14         
     15    .. method:: detach() 
     16         
     17        Remove this item from its plot 
     18         
     19    .. method:: data_rect() 
     20         
     21        Returns the bounding rectangle of this item in data coordinates. This method is used in autoscale calculations.  
     22         
     23    .. method:: set_data_rect(rect) 
     24         
     25        :param rect: The new bounding rectangle in data coordinates 
     26        :type rect: :obj:`.QRectF` 
     27         
    628.. autoclass:: OWCurve 
    729    :members: 
     
    2042class OWCurve(orangeplot.Curve): 
    2143    """ 
    22         This class represents a curve on a plot.       
     44        This class represents a curve on a plot. 
    2345    """ 
    2446    def __init__(self, xData=[], yData=[], x_axis_key=xBottom, y_axis_key=yLeft, tooltip=None, parent=None, scene=None): 
  • orange/OrangeWidgets/plot/owplot.py

    r8540 r8547  
    11''' 
     2 
     3.. index:: plot 
     4 
    25############################## 
    36Plot (``owplot``) 
     
    58 
    69.. autoclass:: OrangeWidgets.plot.OWPlot 
    7     :members: 
    8     :show-inheritance: 
    910     
    1011''' 
     
    6263    "setTickLength" : "set_axis_tick_length", 
    6364    "updateCurves" : "update_curves", 
    64     "itemList" : "plot_items" 
     65    "itemList" : "plot_items", 
     66    "setShowMainTitle" : "set_show_main_title", 
     67    "setMainTitle" : "set_main_title", 
     68    "inv_transform" : "invTransform" 
    6569} 
    6670 
     
    7074    The base class for all plots in Orange. It uses the Qt Graphics View Framework 
    7175    to draw elements on a graph.  
    72          
    73     .. attribute:: show_legend 
    74      
    75         A boolean controlling whether the legend is displayed or not 
    76          
    77     .. attribute:: show_main_title 
    78      
    79         Controls whether or not the main plot title is displayed 
    80          
    81     .. attribute:: main_title 
    82      
    83         The plot title, usually show on top of the plot 
    84          
    85     .. attribute:: zoom_transform 
    86          
    87         Contains the current zoom transformation  
     76     
     77    **Plot layout** 
     78     
     79        .. attribute:: show_legend 
     80     
     81            A boolean controlling whether the legend is displayed or not 
     82         
     83        .. attribute:: show_main_title 
     84     
     85            Controls whether or not the main plot title is displayed 
     86             
     87        .. attribute:: main_title 
     88         
     89            The plot title, usually show on top of the plot 
     90             
     91        .. attribute:: zoom_transform 
     92             
     93            Contains the current zoom transformation  
     94             
     95        .. automethod:: set_main_title 
     96         
     97        .. automethod:: set_show_main_title 
     98     
     99    **Coordinate transformation** 
     100     
     101        .. attribute zoom_transform 
     102         
     103            A QTransform that contains the current zoom transformation 
     104         
     105        .. automethod:: map_to_graph 
     106         
     107        .. automethod:: map_from_graph 
     108         
     109        .. automethod:: transform 
     110         
     111        .. automethod:: inv_transform 
     112         
     113         
     114    **Data curves** 
     115         
     116         
     117        .. automethod:: add_curve 
     118         
     119        .. automethod:: add_custom_curve 
     120         
     121        .. automethod:: add_marker 
     122         
     123        .. method:: add_item 
     124         
     125            Adds any PlotItem to this plot 
     126             
     127    **Axes** 
     128     
     129        .. automethod:: add_axis 
     130         
     131        .. automethod:: add_custom_axis 
     132         
     133        .. automethod:: set_axis_enabled 
     134         
     135        .. automethod:: set_axis_labels 
     136         
     137        .. automethod:: set_axis_scale 
     138     
    88139    """ 
    89140    def __init__(self, parent = None,  name = "None",  show_legend = 1, axes = [xBottom, yLeft] ): 
     
    286337        self.state = SELECT_POLYGON 
    287338         
    288     def setShowMainTitle(self, b): 
     339    def set_show_main_title(self, b): 
    289340        ''' 
    290341            Shows the main title if ``b`` is ``True``, and hides it otherwise.  
     
    293344        self.replot() 
    294345 
    295     def setMainTitle(self, t): 
     346    def set_main_title(self, t): 
    296347        ''' 
    297348            Sets the main title to ``t`` 
     
    346397    def set_axis_labels(self, axis_id, labels): 
    347398        ''' 
    348             Sets the labels of axis ``axis_id`` to ``labels``. This changes the axis scale and removes any previous scale 
    349             set with :meth:`set_axis_scale`.  
     399            Sets the labels of axis ``axis_id`` to ``labels``. This is used for axes displaying a discrete data type.  
     400             
     401            :param labels: The ID of the axis to change 
     402            :type labels: int 
     403             
     404            :param labels: The list of labels to be displayed along the axis 
     405            :type labels: A list of strings 
     406             
     407            .. note:: This changes the axis scale and removes any previous scale set with :meth:`set_axis_scale`.  
    350408        ''' 
    351409        if axis_id in self._bounds_cache: 
     
    356414    def set_axis_scale(self, axis_id, min, max, step_size=0): 
    357415        ''' 
    358             Sets the labels of axis ``axis_id`` to ``labels``. This changes the axis scale and removes any previous labels 
    359             set with :meth:`set_axis_labels`.  
     416            Sets the scale of axis ``axis_id`` to show an interval between ``min`` and ``max``.  
     417            If ``step`` is specified and non-zero, it determines the steps between label on the axis.  
     418            Otherwise, they are calculated automatically.  
     419             
     420            .. note:: This changes the axis scale and removes any previous labels set with :meth:`set_axis_labels`.  
    360421        ''' 
    361422        qDebug('Setting axis scale for ' + str(axis_id) + ' with axes ' + ' '.join(str(i) for i in self.axes)) 
     
    394455            Adds a custom PlotItem ``curve`` to the plot.  
    395456            If ``enableLegend`` is ``True``, a curve symbol defined by  
    396             :meth:`OrangeWidgets.plot.OWCurve.point_item` and the ``curve``'s name 
    397             :obj:`OrangeWidgets.plot.OWCurve.name` is added to the legend.  
     457            :meth:`.OWCurve.point_item` and the ``curve``'s name 
     458            :obj:`.OWCurve.name` is added to the legend.  
     459             
     460            :param curve: The curve to add 
     461            :type curve: :obj:`.OWCurve` 
    398462        ''' 
    399463        self.add_item(curve) 
     
    415479                 x_axis_key = xBottom, y_axis_key = yLeft): 
    416480        ''' 
    417             Creates a new :obj:`OrangeWidgets.plot.OWCurve` with the specified parameters and adds it to the graph.  
     481            Creates a new :obj:`.OWCurve` with the specified parameters and adds it to the graph.  
    418482            If ``enableLegend`` is ``True``, a curve symbol is added to the legend.  
    419483        ''' 
     
    9861050            return margin + (value-m)/(M-m) * size 
    9871051         
    988     def invTransform(self, axis_id, value): 
     1052    def inv_transform(self, axis_id, value): 
    9891053        if axis_id in XAxes: 
    9901054            size = self.graph_area.width() 
  • orange/OrangeWidgets/plot/owtools.py

    r8535 r8547  
    33Plot tools (``owtools``) 
    44############################## 
     5 
     6.. autofunction:: resize_plot_item_list 
     7 
     8.. autofunction:: move_item 
     9 
     10.. autofunction:: move_item_xy 
    511 
    612.. autoclass:: TooltipManager 
     
    3945        If the list is to be reduced, i.e. if len(lst) > size, then the extra items are first removed from the scene. 
    4046        If items have to be added to the scene, new items will be of type ``item_type`` and will have ``parent`` 
    41         as their parent item.  
     47        as their parent item. 
     48         
     49        :param lst: The list to be resized 
     50        :type lst: List of QGraphicsItems 
     51         
     52        :param size: The needed size of the list 
     53        :type size: int 
     54         
     55        :param item_type: The type of items that should be added if the list has to be increased 
     56        :type item_type: type 
     57         
     58        :param parent: Any new items will have this as their parent item 
     59        :type parent: QGraphicsItem 
     60         
     61        :rtype: List of QGraphicsItems 
     62        :returns: The resized list 
    4263    """ 
    4364    n = len(lst) 
     
    5576 
    5677def move_item(item, pos, duration = None): 
     78    ''' 
     79        Animates ``item`` to move to position ``pos``.  
     80        If animations are turned off globally, the item is instead move immediately, without any animation.  
     81         
     82        :param item: The item to move 
     83        :type item: QGraphicsItem 
     84         
     85        :param pos: The final position of the item 
     86        :type pos: QPointF 
     87         
     88        :param duration: The duration of the animation. If unspecified, Qt's default value of 250 miliseconds is used. 
     89        :type duration: int 
     90    ''' 
    5791    for a in _animations: 
    5892        if a.state() == QPropertyAnimation.Stopped: 
     
    70104 
    71105def move_item_xy(item, x, y, duration = None): 
     106    ''' 
     107        Same as  
     108        move_item(item, QPointF(x, y), duration) 
     109    ''' 
    72110    move_item(item, QPointF(x, y), duration) 
    73111         
Note: See TracChangeset for help on using the changeset viewer.