From: John H. <jdh...@ac...> - 2005-03-31 14:32:16
|
>>>>> "Jan" =3D=3D Jan Rienyer Gadil <jr...@gm...> writes: Jan> ok, so i've done plotting two list on boa/wxpython now, i Jan> want to add labels and everything else to my graph... adding Jan> labels i've done this: Glad to see you are getting this working... self.figure =3D Figure()=20 self.axes =3D self.figure.add_subplot(111)=20=20=20=20=20=20=20 self.axes.plot(parent.listX,parent.listY, 'bo')=20=20=20=20=20=20 self.axes.xlabel(parent.Xaxis.GetStringSelection()) Jan> AttributeError: Subplot instance has no attribute 'xlabel' Rather than giving you the answer, I'll show you how to find it.... You can use python's introspection capability (help, dir, type) to ask an object about itself. You can insert print statements directly into your code print dir(self.axes) # see below the results of dir(self.axes) and look for methods that have the right names. Or you can keep a python shell open and use the python help system. If for example, at the shell you do help(self.axes), you'll find Help on instance of Subplot: <matplotlib.axes.Subplot instance> So self.axes is a Subplot instance. You can then import the Subplot class and get much richer help by doing >>> from matplotlib.axes import Subplot >>> help(Subplot)=20=20 If you don't like working from the shell, head on over to the class docs at http://matplotlib.sourceforge.net/classdocs.html and click on the "axes" link and near the top of your screen you'll seen a link that reads Subplot(SubplotBase, Axes) That means the subplot class is derived from SubplotBase and Axes. Click on Subplot, and read through the available methods. If you get impatient, search the web page for "xlabel" Good luck! JDH Python 2.3.3 (#2, Apr 13 2004, 17:41:29) [GCC 3.3.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from matplotlib.figure import Figure >>> fig =3D Figure() >>> ax =3D fig.add_subplot(111) >>> help(ax) >>> dir(ax) ['__doc__', '__init__', '__module__', '_alpha', '_axisbg', '_cid', '_clipon= ', '_connected', '_contourHelper', '_contourLabeler', '_cursorProps', '_eve= nts', '_frameon', '_get_lines', '_get_patches_for_fill', '_get_verts_in_dat= a_coords', '_gridOn', '_hold', '_init_axis', '_label', '_lod', '_position',= '_send_xlim_event', '_send_ylim_event', '_set_artist_props', '_set_lim_and= _transforms', '_sharex', '_sharey', '_transform', '_transformSet', '_visibl= e', 'add_artist', 'add_collection', 'add_line', 'add_patch', 'add_table', '= aname', 'artists', 'autoscale_view', 'axesPatch', 'axhline', 'axhspan', 'ax= ison', 'axvline', 'axvspan', 'bar', 'barh', 'bbox', 'bottom', 'boxplot', 'c= la', 'clabel', 'clear', 'clipbox', 'cohere', 'colNum', 'collections', 'conn= ect', 'contour', 'contourf', 'csd', 'dataLim', 'disconnect', 'draw', 'error= bar', 'figBottom', 'figH', 'figLeft', 'figW', 'figure', 'fill', 'fmt_xdata'= , 'fmt_ydata', 'format_coord', 'format_xdata', 'format_ydata', 'get_alpha',= 'get_axis_bgcolor', 'get_child_artists', 'get_clip_on', 'get_cursor_props'= , 'get_figure', 'get_frame', 'get_images', 'get_label', 'get_legend', 'get_= lines', 'get_position', 'get_transform', 'get_visible', 'get_xaxis', 'get_x= gridlines', 'get_xlim', 'get_xscale', 'get_xticklabels', 'get_xticklines', = 'get_xticks', 'get_yaxis', 'get_ygridlines', 'get_ylim', 'get_yscale', 'get= _yticklabels', 'get_yticklines', 'get_yticks', 'get_zorder', 'grid', 'has_d= ata', 'hist', 'hlines', 'hold', 'images', 'imshow', 'in_axes', 'is_figure_s= et', 'is_first_col', 'is_first_row', 'is_last_col', 'is_last_row', 'is_tran= sform_set', 'ishold', 'left', 'legend', 'legend_', 'lines', 'loglog', 'numC= ols', 'numRows', 'panx', 'pany', 'patches', 'pcolor', 'pcolor_classic', 'pi= ck', 'pie', 'plot', 'plot_date', 'psd', 'quiver', 'right', 'rowNum', 'scale= d', 'scatter', 'scatter_classic', 'semilogx', 'semilogy', 'set_alpha', 'set= _axis_bgcolor', 'set_axis_off', 'set_axis_on', 'set_clip_box', 'set_clip_on= ', 'set_cursor_props', 'set_figure', 'set_frame_on', 'set_label', 'set_lod'= , 'set_position', 'set_title', 'set_transform', 'set_visible', 'set_xlabel'= , 'set_xlim', 'set_xscale', 'set_xticklabels', 'set_xticks', 'set_ylabel', = 'set_ylim', 'set_yscale', 'set_yticklabels', 'set_yticks', 'set_zorder', 's= pecgram', 'spy', 'spy2', 'stem', 'table', 'tables', 'text', 'texts', 'title= ', 'toggle_log_lineary', 'top', 'transAxes', 'transData', 'update', 'update= _datalim', 'update_datalim_numerix', 'update_from', 'viewLim', 'vlines', 'x= axis', 'yaxis', 'zoomx', 'zoomy', 'zorder'] >>> |