On Friday, July 27, 2012, JonBL wrote:
>
> I'm unsure about the role of numpy method arange in Matplotlib plots. All
> Matplotlib examples I have seen call numpy's method arange, and pass the
> result as the first arg to Matplotlib's plot method.
>
> But the following works as expected:
>
> --- quote ---
> import matplotlib.pyplot as plt
> import numpy as np
>
> dom = [1, 3, 4, 5, 7] # Plot domain on x-axis in ascending order
> of values
> ran = [7, -2, 11, 5.8, 0] # Plot range on y-axis in 1-to-1
> correspondence
> with domain items
>
> fig = plt.figure()
> ax = plt.subplot(111)
> ax.plot(dom, ran)
> plt.grid()
> plt.show()
> --- end quote ---
>
> I'm not calling numpy.arange(arg) here, but I see the expected plot of 5
> co-ordinate points. When should I use numpy.arange(arg) instead of what I
> have done above? Something to do with the domain that I want to include in
> the plot?
>
> TIA,
> Jon
>
>
Nothing is special about arange, it is just a way to generate an array of
floating point numbers, much like python's range(). You can specify start
and end values and the stepsize as well, just like for range(), except the
stepsize can be a floating point number.
In many examples, you could use python's range() and get the same results.
All that is important is to provide coordinates for each need dimension,
from arange(), linspace(), range(), or some other source.
I hope that clears it up.
Ben Root
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users