plot(x,y) Trouble?

plot(2.8,3.4) doesn't work in my program

Why should it?

I believe it should.

Plot takes once or two *sequences* of numbers as arguments.

I don't think it would be so complicated for the "plot" code to check
for the type of the input arguments and then create a list (or a
sequence) on the fly, i.e. (pseudo-code, untested):

if isinstance(x, types.IntType):
x = [x]

The same apply for the second input.

As it appears to work in tools like Matlab, I don't see why MPL should
not support it. But then, I am no expert in MPL so it might be
difficult to do it for other reasons.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
http://thedoomedcity.blogspot.com/

···

On 21 February 2010 15:44, Alan G Isaac wrote:

On 2/21/2010 10:29 AM, Wayne Watson wrote:

Or rather:

    np.atleast_1d

Gaël

···

On Sun, Feb 21, 2010 at 03:52:41PM +0000, Andrea Gavana wrote:

On 21 February 2010 15:44, Alan G Isaac wrote:
> On 2/21/2010 10:29 AM, Wayne Watson wrote:
>> plot(2.8,3.4) doesn't work in my program

> Why should it?

I believe it should.

> Plot takes once or two *sequences* of numbers as arguments.

I don't think it would be so complicated for the "plot" code to check
for the type of the input arguments and then create a list (or a
sequence) on the fly, i.e. (pseudo-code, untested):

if isinstance(x, types.IntType):
x = [x]

It does in svn -- though it unhelpfully plots a line segment with one
vertex (invisible). Eric, I think you added this support. For length
one sequences, perhaps we should default to a marker?

···

On Sun, Feb 21, 2010 at 9:52 AM, Andrea Gavana <andrea.gavana@...287...> wrote:

On 21 February 2010 15:44, Alan G Isaac wrote:

On 2/21/2010 10:29 AM, Wayne Watson wrote:

plot(2.8,3.4) doesn't work in my program

Why should it?

I believe it should.

John Hunter wrote:

plot(2.8,3.4) doesn't work in my program

Why should it?

I believe it should.

It does in svn -- though it unhelpfully plots a line segment with one
vertex (invisible). Eric, I think you added this support. For length
one sequences, perhaps we should default to a marker?

I don't think so; this strikes me as a step too far. Anyone plotting a single point should know that they need a marker, and that they have to specify which marker to use. If they don't know it, they need to learn it PDQ. There is a limit to the usefulness of trying to guess, or provide defaults, and providing a default marker for this case is beyond that limit. A reasonable argument could be made that I should not even have added the non-sequence support.

Eric

···

On Sun, Feb 21, 2010 at 9:52 AM, Andrea Gavana <andrea.gavana@...287...> wrote:

On 21 February 2010 15:44, Alan G Isaac wrote:

On 2/21/2010 10:29 AM, Wayne Watson wrote:

I've searched and searched the online docs...please help.

DG

Hi David,

I found this one::

xticks( arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue') )

On the page

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.xticks

If I had that problem I would try to do something like that:

xvalues = linspace(0,100,1000)

xticks(xvalues, ["%.2f" % val for val in xvalues])

# or, with a lambda expression, but in #python they say
# a list comprehension is better (faster)

xticks(xvalues, map(lambda i : "%.2f" % i, xvalues))

The side effect is, of course, that the tick is not exactly at the position he
indicates. Maybe you better use "arange()" to get the right values for your
ticks, just make sure that they cover the interval your xvalues are in.

If you find a better solution, please let me know.

Best regards,
Philipp

David Goldsmith wrote:

I've searched and searched the online docs...please help.

DG
  

If I understand your question correctly you probably need to look at
http://matplotlib.sourceforge.net/api/ticker_api.html#tick-formatting

ax.xaxis.set_major_formatter( xmajorFormatter )
ax.xaxis.set_minor_formatter( xminorFormatter )

- Steve

Hi,

I'm using the Python(x,y) distribution which comes with matplotlib for
Windows. My OS is Windows XP with all updates and service packs on an
AMD Athlon 2600+ PC with ATI Radeon 9600 graiphics card.

Python will work fine for anything that doesn't import the pylab
component (I can import matplotlib itself no problem as well as numpy
etc) but if I try to import pylab I get:-

"An unhandled exception occured in pythonw.exe [3976]"

I've tied reinstalling Python(x,y) and even reinstalling windows then
Python(x,y) but to no avail. This seems odd to me as 2 other PCs at work
install Python(x,y) and run Pylab fine.

Any suggestions as to what I should check to track down this error?

Thanks

Jon

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4888 (20100222) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com