Re: [Matplotlib-users] incremental colors for lines

2011-05-10 Thread Daniel Mader
Hi, I like this, too.

However, I don't understand why it works at all. Usually, when I apply
a colormap, I need to take care about the scaling myself, i.e. divide
the range up into the number of elements to plot:

import pylab as pl
import matplotlib.cm as cm

xval = pl.arange(0, 20, 0.2)
n = 256
for i in range(n):
#   pl.plot(xval, pl.sin(xval)+i, c=cm.hot(i), lw=5)
   pl.plot(xval, pl.sin(xval)+i, c=cm.hot(1.*i/n), lw=5)

Can anyone tell me why this is not necessary here but essential for
example here:

for i,infile in enumerate(infiles):
## title for plot
tname = os.path.splitext(infile)[0]

## read data
f = FileHelpers.BlockedFile(infile)

alldata = scipy.array([[],[]])
for ii in ['+', '2', 'x', '1']: # use for markers, too
#for ii in [4,3,2,1]: # use for markers, too
try:
f.next_block()
data = scipy.loadtxt(f).T
alldata = scipy.concatenate((alldata, data), axis=1)
#ax.plot(data[0],data[1], '%s'%ii,
color=cm.hot(1.*i/len(infiles)), mew=1.5 )
ax.plot(data[0],data[1], '%s'%ii, c=cm.hot(i), mew=1.5 )
except Exception, e:
print e
break

Thanks in advance,
Daniel


 I have found a simple and better way. One can chose from colors from a
 color
 map:

 import pylab as pl
 import matplotlib.cm as cm
 xval = pl.arange(0, 20, 0.2)
 for i in range(256):
     ...  pl.plot(xval, pl.sin(xval)+i, c=cm.hot(i), lw=5)

 This one if, for instance, picking from a color map called hot. If one
 wants to the colors to fade away, or darken, the alpha option can be
 utilized or another color map in which colors darken or fade into another
 color.

 There is no need for a long sophisticated script.

--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] imshow in Axes3D?

2011-05-10 Thread Jonathan Slavin
Hi,

I would like to create a plot with a series of parallel 2-D slices in
order to illustrate 3-D data.  I got excited when I saw the example of
translucent bar plots, which is similiar in some ways to what I had in
mind.  But it seems that there is no imshow method in Axes3D.  How hard
would that be to add?  (By the way, I do know about mayavi and have used
it, but there are things about it that make it somewhat difficult to
work with.)

Jon
-- 
__
Jonathan D. Slavin  Harvard-Smithsonian CfA
jsla...@cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981   Cambridge, MA 02138-1516
 cell: (781) 363-0035   USA
__


--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] imshow in Axes3D?

2011-05-10 Thread Benjamin Root
On Tue, May 10, 2011 at 9:25 AM, Jonathan Slavin jsla...@cfa.harvard.eduwrote:

 Hi,

 I would like to create a plot with a series of parallel 2-D slices in
 order to illustrate 3-D data.  I got excited when I saw the example of
 translucent bar plots, which is similiar in some ways to what I had in
 mind.  But it seems that there is no imshow method in Axes3D.  How hard
 would that be to add?  (By the way, I do know about mayavi and have used
 it, but there are things about it that make it somewhat difficult to
 work with.)

 Jon


imshow() and friends work a little bit differently from the other plotting
commands.  Unlike the other plotting functions, imshow() does not return any
Collection objects, rather it returns an AxesImage object.  Most of the
other functions are merely wrappers around their 2D equivalent with a few
extra keyword arguments and a 2D to 3D converter call for the collection
objects returned.  In order to support imshow() in Axes3D, a 3D version of
the AxesImage object will need to be made and should be able to be created
from an existing 2D version.

If someone wants to create a 3D version of AxesImage and add it to art3d.py,
I would be more than happy to take the patch.  But at this time, I am too
unfamiliar with AxesImage objects and am more focused on fixing the current
feature-set.

Ben Root
--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Feature request: automatic scaling of subplots, margins, etc

2011-05-10 Thread Jae-Joon Lee
On Fri, May 6, 2011 at 5:20 PM, Daniel Mader
danielstefanma...@googlemail.com wrote:
 From many postings here I have learned that
 this is the absolute intention, i.e. it is broken by design unless the
 programmer takes care about this.

I think there are pros and cons, and I don't think the current design
is simply broken.
For example, it will be very distracting if the axes area changes
while you're doing some interactive stuff (e.g., panning). Anyhow I
admit that the default layout may not be optimal for figures with
multiple subplots, and there is a room for improvement.

There are a few approach you can take.

 * If you're only interested in saved outputs, you may use savefig
with bbox_inches=tight. Note that this changes the size of figure.

 * Use Tony's script to adjust the subplot params automatically.

 * use axes_grid1 toolkit which enables you to change the axes
position on the fly. Check
http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg18743.html.
For current git master branch, check
examples/axes_grid/make_room_for_ylabel_using_axesgrid.py

Regards,

-JJ

--
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users