.. include:: headings.inc .. currentmodule:: lib.plot .. highlight:: python .. _lib.plot.PlotCanvas: ========================================================================================================================================== |phoenix_title| **PlotCanvas** ========================================================================================================================================== Subclass of a wx.Panel which holds two scrollbars and the actual plotting canvas (self.canvas). It allows for simple general plotting of data with zoom, labels, and automatic axis scaling. | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **PlotCanvas** .. raw:: html

Inheritance diagram of PlotCanvas

| |super_classes| Known Superclasses ================================== :class:`Panel` | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~lib.plot.PlotCanvas.__init__` Constructs a panel, which can be a child of a frame or :meth:`~lib.plot.PlotCanvas.Clear` Erase the window. :meth:`~lib.plot.PlotCanvas.Draw` Wrapper around _Draw, which handles log axes :meth:`~lib.plot.PlotCanvas.GetClosestPoint` Returns list with :meth:`~lib.plot.PlotCanvas.GetClosestPoints` Returns list with :meth:`~lib.plot.PlotCanvas.GetEnableAntiAliasing` :meth:`~lib.plot.PlotCanvas.GetEnableCenterLines` True if grid enabled. :meth:`~lib.plot.PlotCanvas.GetEnableDiagonals` True if grid enabled. :meth:`~lib.plot.PlotCanvas.GetEnableDrag` :meth:`~lib.plot.PlotCanvas.GetEnableGrid` True if grid enabled. :meth:`~lib.plot.PlotCanvas.GetEnableHiRes` :meth:`~lib.plot.PlotCanvas.GetEnableLegend` True if Legend enabled. :meth:`~lib.plot.PlotCanvas.GetEnablePointLabel` True if pointLabel enabled. :meth:`~lib.plot.PlotCanvas.GetEnableTitle` True if title enabled. :meth:`~lib.plot.PlotCanvas.GetEnableZoom` True if zooming enabled. :meth:`~lib.plot.PlotCanvas.GetFontSizeAxis` Get current tick and axis label font size in points :meth:`~lib.plot.PlotCanvas.GetFontSizeLegend` Get current Legend font size in points :meth:`~lib.plot.PlotCanvas.GetFontSizeTitle` Get current Title font size in points :meth:`~lib.plot.PlotCanvas.GetGridColour` :meth:`~lib.plot.PlotCanvas.getLogScale` :meth:`~lib.plot.PlotCanvas.GetPointLabelFunc` Returns pointLabel Drawing Function :meth:`~lib.plot.PlotCanvas.GetShowScrollbars` Set ``True`` to show scrollbars :meth:`~lib.plot.PlotCanvas.GetUseScientificNotation` :meth:`~lib.plot.PlotCanvas.GetXCurrentRange` :meth:`~lib.plot.PlotCanvas.GetXMaxRange` :meth:`~lib.plot.PlotCanvas.GetXSpec` Returns current XSpec for axis :meth:`~lib.plot.PlotCanvas.GetXY` Wrapper around _getXY, which handles log scales :meth:`~lib.plot.PlotCanvas.GetYCurrentRange` :meth:`~lib.plot.PlotCanvas.GetYMaxRange` :meth:`~lib.plot.PlotCanvas.GetYSpec` Returns current YSpec for axis :meth:`~lib.plot.PlotCanvas.OnLeave` Used to erase pointLabel when mouse outside window :meth:`~lib.plot.PlotCanvas.OnMotion` :meth:`~lib.plot.PlotCanvas.OnMouseDoubleClick` :meth:`~lib.plot.PlotCanvas.OnMouseLeftDown` :meth:`~lib.plot.PlotCanvas.OnMouseLeftUp` :meth:`~lib.plot.PlotCanvas.OnMouseRightDown` :meth:`~lib.plot.PlotCanvas.OnPaint` :meth:`~lib.plot.PlotCanvas.OnScroll` :meth:`~lib.plot.PlotCanvas.OnSize` :meth:`~lib.plot.PlotCanvas.PageSetup` Brings up the page setup dialog :meth:`~lib.plot.PlotCanvas.PositionScreenToUser` Converts Screen position to User Coordinates :meth:`~lib.plot.PlotCanvas.PositionUserToScreen` Converts User position to Screen Coordinates :meth:`~lib.plot.PlotCanvas.Printout` Print current plot. :meth:`~lib.plot.PlotCanvas.PrintPreview` Print-preview current plot. :meth:`~lib.plot.PlotCanvas.Redraw` Redraw the existing plot. :meth:`~lib.plot.PlotCanvas.Reset` Unzoom the plot. :meth:`~lib.plot.PlotCanvas.SaveFile` Saves the file to the type specified in the extension. If no file :meth:`~lib.plot.PlotCanvas.ScrollRight` Move view right number of axis units. :meth:`~lib.plot.PlotCanvas.ScrollUp` Move view up number of axis units. :meth:`~lib.plot.PlotCanvas.SetCursor` :meth:`~lib.plot.PlotCanvas.SetEnableAntiAliasing` Set ``True`` to enable anti-aliasing. :meth:`~lib.plot.PlotCanvas.SetEnableCenterLines` Set True, 'Horizontal' or 'Vertical' to enable center line(s). :meth:`~lib.plot.PlotCanvas.SetEnableDiagonals` Set True, 'Bottomleft-Topright' or 'Bottomright-Topleft' to enable :meth:`~lib.plot.PlotCanvas.SetEnableDrag` Set ``True`` to enable drag. :meth:`~lib.plot.PlotCanvas.SetEnableGrid` Set True, 'Horizontal' or 'Vertical' to enable grid. :meth:`~lib.plot.PlotCanvas.SetEnableHiRes` Set ``True`` to enable high-resolution mode when using anti-aliasing. :meth:`~lib.plot.PlotCanvas.SetEnableLegend` Set ``True`` to enable legend. :meth:`~lib.plot.PlotCanvas.SetEnablePointLabel` Set ``True`` to enable pointLabel. :meth:`~lib.plot.PlotCanvas.SetEnableTitle` Set ``True`` to enable title. :meth:`~lib.plot.PlotCanvas.SetEnableZoom` Set ``True`` to enable zooming. :meth:`~lib.plot.PlotCanvas.SetFontSizeAxis` Set the tick and axis label font size (default is 10 point) :meth:`~lib.plot.PlotCanvas.SetFontSizeLegend` Set Legend font size (default is 7 point) :meth:`~lib.plot.PlotCanvas.SetFontSizeTitle` Set Title font size (default is 15 point) :meth:`~lib.plot.PlotCanvas.SetGridColour` :meth:`~lib.plot.PlotCanvas.setLogScale` :meth:`~lib.plot.PlotCanvas.SetPointLabelFunc` Sets the function with custom code for pointLabel drawing :meth:`~lib.plot.PlotCanvas.SetShowScrollbars` Set ``True`` to show scrollbars :meth:`~lib.plot.PlotCanvas.SetUseScientificNotation` :meth:`~lib.plot.PlotCanvas.SetXSpec` xSpec- defines x axis type. Can be 'none', 'min' or 'auto' :meth:`~lib.plot.PlotCanvas.SetYSpec` ySpec- defines x axis type. Can be 'none', 'min' or 'auto' :meth:`~lib.plot.PlotCanvas.UpdatePointLabel` Updates the pointLabel point on screen with data contained in :meth:`~lib.plot.PlotCanvas.Zoom` Zoom on the plot ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~lib.plot.PlotCanvas.pageSetupData` :attr:`~lib.plot.PlotCanvas.print_data` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: PlotCanvas(Panel) Subclass of a wx.Panel which holds two scrollbars and the actual plotting canvas (self.canvas). It allows for simple general plotting of data with zoom, labels, and automatic axis scaling. .. method:: __init__(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=0, name="plotCanvas") Constructs a panel, which can be a child of a frame or any other non-control window .. method:: Clear(self) Erase the window. .. method:: Draw(self, graphics, xAxis = None, yAxis = None, dc = None) Wrapper around _Draw, which handles log axes .. method:: GetClosestPoint(self, pntXY, pointScaled= True) Returns list with [curveNumber, legend, index of closest point, pointXY, scaledXY, distance] list for only the closest curve. Returns [] if no curves are being plotted. x, y in user coords if pointScaled == ``True`` based on screen coords if pointScaled == ``False`` based on user coords .. method:: GetClosestPoints(self, pntXY, pointScaled= True) Returns list with [curveNumber, legend, index of closest point, pointXY, scaledXY, distance] list for each curve. Returns [] if no curves are being plotted. x, y in user coords if pointScaled == ``True`` based on screen coords if pointScaled == ``False`` based on user coords .. method:: GetEnableAntiAliasing(self) .. method:: GetEnableCenterLines(self) True if grid enabled. .. method:: GetEnableDiagonals(self) True if grid enabled. .. method:: GetEnableDrag(self) .. method:: GetEnableGrid(self) True if grid enabled. .. method:: GetEnableHiRes(self) .. method:: GetEnableLegend(self) True if Legend enabled. .. method:: GetEnablePointLabel(self) True if pointLabel enabled. .. method:: GetEnableTitle(self) True if title enabled. .. method:: GetEnableZoom(self) True if zooming enabled. .. method:: GetFontSizeAxis(self) Get current tick and axis label font size in points .. method:: GetFontSizeLegend(self) Get current Legend font size in points .. method:: GetFontSizeTitle(self) Get current Title font size in points .. method:: GetGridColour(self) .. method:: getLogScale(self) .. method:: GetPointLabelFunc(self) Returns pointLabel Drawing Function .. method:: GetShowScrollbars(self) Set ``True`` to show scrollbars .. method:: GetUseScientificNotation(self) .. method:: GetXCurrentRange(self) .. method:: GetXMaxRange(self) .. method:: GetXSpec(self) Returns current XSpec for axis .. method:: GetXY(self, event) Wrapper around _getXY, which handles log scales .. method:: GetYCurrentRange(self) .. method:: GetYMaxRange(self) .. method:: GetYSpec(self) Returns current YSpec for axis .. method:: OnLeave(self, event) Used to erase pointLabel when mouse outside window .. method:: OnMotion(self, event) .. method:: OnMouseDoubleClick(self,event) .. method:: OnMouseLeftDown(self,event) .. method:: OnMouseLeftUp(self, event) .. method:: OnMouseRightDown(self,event) .. method:: OnPaint(self, event) .. method:: OnScroll(self, evt) .. method:: OnSize(self,event) .. method:: PageSetup(self) Brings up the page setup dialog .. method:: PositionScreenToUser(self, pntXY) Converts Screen position to User Coordinates .. method:: PositionUserToScreen(self, pntXY) Converts User position to Screen Coordinates .. method:: Printout(self, paper=None) Print current plot. .. method:: PrintPreview(self) Print-preview current plot. .. method:: Redraw(self, dc=None) Redraw the existing plot. .. method:: Reset(self) Unzoom the plot. .. method:: SaveFile(self, fileName= '') Saves the file to the type specified in the extension. If no file name is specified a dialog box is provided. Returns ``True`` if sucessful, otherwise False. .bmp Save a Windows bitmap file. .xbm Save an X bitmap file. .xpm Save an XPM bitmap file. .png Save a Portable Network Graphics file. .jpg Save a Joint Photographic Experts Group file. .. method:: ScrollRight(self, units) Move view right number of axis units. .. method:: ScrollUp(self, units) Move view up number of axis units. .. method:: SetCursor(self, cursor) .. method:: SetEnableAntiAliasing(self, enableAntiAliasing) Set ``True`` to enable anti-aliasing. .. method:: SetEnableCenterLines(self, value) Set True, 'Horizontal' or 'Vertical' to enable center line(s). .. method:: SetEnableDiagonals(self, value) Set True, 'Bottomleft-Topright' or 'Bottomright-Topleft' to enable center line(s). .. method:: SetEnableDrag(self, value) Set ``True`` to enable drag. .. method:: SetEnableGrid(self, value) Set True, 'Horizontal' or 'Vertical' to enable grid. .. method:: SetEnableHiRes(self, enableHiRes) Set ``True`` to enable high-resolution mode when using anti-aliasing. .. method:: SetEnableLegend(self, value) Set ``True`` to enable legend. .. method:: SetEnablePointLabel(self, value) Set ``True`` to enable pointLabel. .. method:: SetEnableTitle(self, value) Set ``True`` to enable title. .. method:: SetEnableZoom(self, value) Set ``True`` to enable zooming. .. method:: SetFontSizeAxis(self, point= 10) Set the tick and axis label font size (default is 10 point) .. method:: SetFontSizeLegend(self, point= 7) Set Legend font size (default is 7 point) .. method:: SetFontSizeTitle(self, point= 15) Set Title font size (default is 15 point) .. method:: SetGridColour(self, colour) .. method:: setLogScale(self, logscale) .. method:: SetPointLabelFunc(self, func) Sets the function with custom code for pointLabel drawing ******** more info needed *************** .. method:: SetShowScrollbars(self, value) Set ``True`` to show scrollbars .. method:: SetUseScientificNotation(self, useScientificNotation) .. method:: SetXSpec(self, type= 'auto') xSpec- defines x axis type. Can be 'none', 'min' or 'auto' where: * 'none' - shows no axis or tick mark values * 'min' - shows min bounding box values * 'auto' - rounds axis range to sensible values * - like 'min', but with tick marks .. method:: SetYSpec(self, type= 'auto') ySpec- defines x axis type. Can be 'none', 'min' or 'auto' where: * 'none' - shows no axis or tick mark values * 'min' - shows min bounding box values * 'auto' - rounds axis range to sensible values * - like 'min', but with tick marks .. method:: UpdatePointLabel(self, mDataDict) Updates the pointLabel point on screen with data contained in mDataDict. mDataDict will be passed to your function set by SetPointLabelFunc. It can contain anything you want to display on the screen at the scaledXY point you specify. This function can be called from parent window with onClick, onMotion events etc. .. method:: Zoom(self, Center, Ratio) Zoom on the plot Centers on the X,Y coords given in Center Zooms by the Ratio = (Xratio, Yratio) given .. attribute:: pageSetupData See :meth:`~PlotCanvas.pageSetupData` .. attribute:: print_data See :meth:`~PlotCanvas.print_data`