SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Jan R. G. <jr...@gm...> - 2005年03月31日 07:32:26
i'd just like to ask how to make a simple graph of two lists???
i've seen this in the tutorials...
a = self.fig.add_subplot(111)
t = numpy.arange(0.0,3.0,0.01)
s = numpy.sin(2*numpy.pi*t)
c = numpy.cos(2*numpy.pi*t)
a.plot(t,s)
a.plot(t,c)
=============
so if i am to plot two lists say listY[] and listX[], i should do this:
a.plot(listY, listX)
=============
please, any help will be greatly appreciated!
From: Jan R. G. <jr...@gm...> - 2005年03月31日 09:34:28
ok, so i've done plotting two list on boa/wxpython
now, i want to add labels and everything else to my graph...
adding labels i've done this:
 self.figure = Figure()
 self.axes = self.figure.add_subplot(111)
 
 self.axes.plot(parent.listX,parent.listY, 'bo')
 
 self.axes.xlabel(parent.Xaxis.GetStringSelection())
 self.axes.ylabel(parent.Xaxis.GetStringSelection())
 
 self.canvas = FigureCanvas(self, -1, self.figure)
===========================================
but i'm getting some error that says:
Traceback (most recent call last):
 File "E:\final docu\Folder4.2pssl2\wxFrame1.py", line 729, in
OnGraphOldFileButton
 wxFrame2.create(self).Show(true)
 File "E:\final docu\Folder4.2pssl2\wxFrame2.py", line 16, in create
 return wxFrame2(parent)
 File "E:\final docu\Folder4.2pssl2\wxFrame2.py", line 39, in __init__
 self.axes.xlabel(parent.Xaxis.GetStringSelection())
AttributeError: Subplot instance has no attribute 'xlabel'
==============================================
what should i do???
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']
>>>
From: Mark E. <ma...@st...> - 2005年04月28日 08:43:41
Hi,
I am trying to construct coloured contour maps, but when I do:
from pylab import *
clabel is not there. Was this removed? The docs suggest that clabel 
is part of the pylab module.
thanks,
Mark
From: Mark E. <ma...@st...> - 2005年04月28日 09:03:15
Sorry - problem solved. I was 0.01 versions behind on the computer I 
was using. Thanks for adding such a great feature!
- Mark
On Apr 28, 2005, at 1:43 AM, Mark Engelhardt wrote:
> Hi,
>
> I am trying to construct coloured contour maps, but when I do:
>
> from pylab import *
>
> clabel is not there. Was this removed? The docs suggest that clabel 
> is part of the pylab module.
>
> thanks,
> Mark
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Tell us your software development plans!
> Take this survey and enter to win a one-year sub to SourceForge.net
> Plus IDC's 2005 look-ahead and a copy of this survey
> Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
........................................................................ 
.....
Mark Engelhardt
Pande and Herschlag groups
S257 Clarke Center, 318 Campus Drive
Stanford University, Stanford, CA 94305
ma...@st...
http://www.stanford.edu/~marke/
From: Darren D. <dd...@co...> - 2005年03月31日 14:38:35
On Thursday 31 March 2005 04:34 am, Jan Rienyer Gadil wrote:
> ok, so i've done plotting two list on boa/wxpython
> now, i want to add labels and everything else to my graph...
> adding labels i've done this:
>
> self.figure = Figure()
> self.axes = self.figure.add_subplot(111)
>
> self.axes.plot(parent.listX,parent.listY, 'bo')
>
> self.axes.xlabel(parent.Xaxis.GetStringSelection())
> self.axes.ylabel(parent.Xaxis.GetStringSelection())
>
> self.canvas = FigureCanvas(self, -1, self.figure)
>
> ===========================================
> but i'm getting some error that says:
> Traceback (most recent call last):
> File "E:\final docu\Folder4.2pssl2\wxFrame1.py", line 729, in
> OnGraphOldFileButton
> wxFrame2.create(self).Show(true)
> File "E:\final docu\Folder4.2pssl2\wxFrame2.py", line 16, in create
> return wxFrame2(parent)
> File "E:\final docu\Folder4.2pssl2\wxFrame2.py", line 39, in __init__
> self.axes.xlabel(parent.Xaxis.GetStringSelection())
>
> AttributeError: Subplot instance has no attribute 'xlabel'
>
> ==============================================
> what should i do???
Hi Jan,
axes.xlabel doesnt exist. What you are looking for is 
self.axes.set_xlabel(parent.Xaxis.GetStringSelection())
self.axes.set_ylabel(parent.Xaxis.GetStringSelection())
The Matplotlib devs have put a lot of effort into documenting the project. In 
situations like this, I often end up relying on the python interactive 
interpreter to find the method I am looking for:
from pylab import *
fig = figure()
ax = fig.add_subplot(111)
dir(ax)
or you could add a line in your own code:
 self.figure = Figure()
 self.axes = self.figure.add_subplot(111)
 self.axes.plot(parent.listX,parent.listY, 'bo')
 print dir(self.axes)
both would give you a list of available methods.
Hope this helps,
Darren
From: Jan R. G. <jr...@gm...> - 2005年03月31日 23:59:42
thanks to you all, that's a really big help!!! 
On 2005年3月31日 09:38:26 -0500, Darren Dale <dd...@co...> wrote:
> On Thursday 31 March 2005 04:34 am, Jan Rienyer Gadil wrote:
> > ok, so i've done plotting two list on boa/wxpython
> > now, i want to add labels and everything else to my graph...
> > adding labels i've done this:
> >
> > self.figure = Figure()
> > self.axes = self.figure.add_subplot(111)
> >
> > self.axes.plot(parent.listX,parent.listY, 'bo')
> >
> > self.axes.xlabel(parent.Xaxis.GetStringSelection())
> > self.axes.ylabel(parent.Xaxis.GetStringSelection())
> >
> > self.canvas = FigureCanvas(self, -1, self.figure)
> >
> > ===========================================
> > but i'm getting some error that says:
> > Traceback (most recent call last):
> > File "E:\final docu\Folder4.2pssl2\wxFrame1.py", line 729, in
> > OnGraphOldFileButton
> > wxFrame2.create(self).Show(true)
> > File "E:\final docu\Folder4.2pssl2\wxFrame2.py", line 16, in create
> > return wxFrame2(parent)
> > File "E:\final docu\Folder4.2pssl2\wxFrame2.py", line 39, in __init__
> > self.axes.xlabel(parent.Xaxis.GetStringSelection())
> >
> > AttributeError: Subplot instance has no attribute 'xlabel'
> >
> > ==============================================
> > what should i do???
> 
> Hi Jan,
> 
> axes.xlabel doesnt exist. What you are looking for is
> 
> self.axes.set_xlabel(parent.Xaxis.GetStringSelection())
> self.axes.set_ylabel(parent.Xaxis.GetStringSelection())
> 
> The Matplotlib devs have put a lot of effort into documenting the project. In
> situations like this, I often end up relying on the python interactive
> interpreter to find the method I am looking for:
> 
> from pylab import *
> fig = figure()
> ax = fig.add_subplot(111)
> dir(ax)
> 
> or you could add a line in your own code:
> 
> self.figure = Figure()
> self.axes = self.figure.add_subplot(111)
> 
> self.axes.plot(parent.listX,parent.listY, 'bo')
> print dir(self.axes)
> 
> both would give you a list of available methods.
> 
> Hope this helps,
> 
> Darren
>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /