Re: [Matplotlib-users] making subplots more square

2009-05-25 Thread Eric Firing
per freem wrote:
 hi eric,
 
 i tried your suggestion but it still did not work.  here's a code 
 snippet that demonstrates what i am trying to do:

No, I'm still baffled.  If you stack 3 subplots vertically in a figure 6 
inches high, they are going to be small.  You can fiddle with their 
sizes a bit by using subplots_adjust, but they are still going to be 
small--less than 2 inches high.  What physical dimensions do you want, 
when you say you want the plot to be scaled bigger?

Eric

 
 import matplotlib.pyplot as 
 plt 
 from scipy import 
 * 
   

 
 my_fig = plt.figure(figsize=(7,6), 
 dpi=100) 
 plot_ax1 = 
 plt.subplot(3,1,1)   
 a = 
 rand(100) 

 
 b = rand(100) + 
 rand()  
 plt.scatter(a, 
 b)   
 plot_ax1.set(xticklabels=[])  

 
 plot_ax1.set_aspect('equal', 
 adjustable='box')  
 plt.savefig('myplot.pdf') 
  
 
   
 
 when i run this, i get a small square scatter plot in the middle of the 
 page. i want this plot to be scaled to be bigger.  if i remove the 
 set_aspect() call, the plot becomes bigger in the horizontal direction, 
 and is rectangular.
 
 any ideas how to fix this?  thanks again.
 
 On Sun, May 24, 2009 at 9:24 PM, Eric Firing efir...@hawaii.edu 
 mailto:efir...@hawaii.edu wrote:
 
 per freem wrote:
 
 hi all,
 
 i have a series of subplots organized in a column (3x1). i
 noticed that if i plot them then matplotlib tends to make the
 x-axis long and the y-axis short, so the plot is really
 rectangular. how can i make it more square? if i do:
 
 f = figure(figsize=(7,6), dpi=100)
 p1 = subplot(3,1,1)
 plot()
 # make axes square
 p1.set_aspect('equal')
 
 p2 = subplot(3,1,2)
 plot()
 p2.set_aspect('equal')
 
 # etc for third subplot...
 
 then the subplots i get are square, but very small and squished
 compared to the space they have in the figure (ie what i set in
 figsize.) how can i fix this? i just want to have square axes,
 but have each subplot take up as much space as it would if i
 didnt set square axes... it works fine for the rectangular axes
 case.
 
 
 Maybe what you are looking for is
 p1.set_aspect('equal', adjustable='datalim')
 
 It is not clear from your message, but try the modification above
 and see if it does what you want.
 
 Eric
 
 


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] EMF export doesn't work

2009-05-25 Thread Bryan Cole
On Tue, 2009-05-19 at 10:50 +0200, Thomas Pfaff wrote:
 Hello there,
 
 when I started with matplotlib I was really enthusiastic that I can throw
 all those Excel, IDL, Matlab and whatever else I used until now overboard
 and do everything from data processing to visualization in beloved Python.
 
 Now, here at work I have to use a Windows PC and PowerPoint and graphics
 just look best in PowerPoint if they are in EMF format.
 Funny enough there seems to be no converter on the market to properly
 convert any other vector format matplotlib can produce to EMF. Even the way
 via Inkscape fails even with simple plots.
 
 If I'm wrong about the converter, please tell me and bury EMF-support.
 If not, what would you think would be the effort and the time needed to port
 the emf-backend to the latest version of matplotlib? I might at least give
 it a try.

EMF support in OpenOffice is quite good (OOo uses emf internally, I
believe). You can import either SVG or PDF into OOo-Draw using the
respective OOo-extension and export as emf from there. 

bc



--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plot a triangular mesh

2009-05-25 Thread Robert Cimrman
Ondrej Certik wrote:
 On Fri, May 22, 2009 at 3:37 PM, Ondrej Certik ond...@certik.cz wrote:
 Thanks a lot John. I tried that and it does what I want. I just need
 to convert and probably average my 3 different values at the 3
 vertices of the triangle and color the triangle with that color. When
 I get it working, I'll send you a picture. :)
 
 Ok, I made a progress, it seems it's working. Script and picture
 attached. You can compare to the mayavi plot above, it's almost
 identical now. It took my some time playing with different parameters
 of mpl to get here and I think it looks quite good. Still one can see
 the artefacts though as John predicted, due to mpl not interpolating
 the triangles.

Nice!

Just to prod you a bit: If you want to get rid of the hard mayavi 
dependence of femhub for 3D plots too, you could hack a 
(perspective/whatever) projection of 3D surface to 2D, remove invisible 
faces (normal points backwards) and plot the rest by the painter's 
algorithm (far faces first).

r.

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plot a triangular mesh

2009-05-25 Thread Ondrej Certik
On Mon, May 25, 2009 at 1:03 AM, Robert Cimrman cimrm...@ntc.zcu.cz wrote:
 Ondrej Certik wrote:

 On Fri, May 22, 2009 at 3:37 PM, Ondrej Certik ond...@certik.cz wrote:

 Thanks a lot John. I tried that and it does what I want. I just need
 to convert and probably average my 3 different values at the 3
 vertices of the triangle and color the triangle with that color. When
 I get it working, I'll send you a picture. :)

 Ok, I made a progress, it seems it's working. Script and picture
 attached. You can compare to the mayavi plot above, it's almost
 identical now. It took my some time playing with different parameters
 of mpl to get here and I think it looks quite good. Still one can see
 the artefacts though as John predicted, due to mpl not interpolating
 the triangles.

 Nice!

 Just to prod you a bit: If you want to get rid of the hard mayavi dependence
 of femhub for 3D plots too, you could hack a (perspective/whatever)
 projection of 3D surface to 2D, remove invisible faces (normal points
 backwards) and plot the rest by the painter's algorithm (far faces first).

Well, I spent one afternoon playing with cairo, trying to implement
the triangle interpolation and the result was slower than matplotlib.
So gave up and I'll just use what can be done with mpl currently.

As to mayavi, I'd rather make it easier to install. The only tough
dependency is VTK, that takes lots of time to build, we already got
rid of all the others, so that's good.

Ondrej

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Picking and events question

2009-05-25 Thread jorgesmbox-ml


Hi,
I am trying to use matplotlib to visually explore some data. I started
from the event_handling example code: data_browser.py example, but
wanted to go a bit further. The idea is to have two plots and an image
linked together. The first plot represents a measure calculated from
an image region at different times of the day. Selecting one of this
measures shows the corresponding image, and some other measure calculated
from the individual pixels. Further on, selecting in the image or the
second plot should highlight the corresponding point in the plot or pixel
on the image, respectively (That is, the first plot is linked to the image,
and the image and the second plot are linked together).
My problem is that on the function being called upon and event, I always
get events generated by the image, even when the moused was clicked on one of
the other plots. The plots behave ok.
The coded below is a simplified functional version (the measures here are
trivial, and I haven't included the actions when the user selects the image or
the second plot), which exhibits this behavior. What I see when executing this
code is for example:

Actions (click on)  Results (from the print statement on the
onpick() function)

plot1   plot1
image2

image2  image2

plot3   plot3
image2

Am I doing something wrong? I am new to both python and matplotlib, so if you
see something that could be done in a better way, please tell me.

Jorges


- Test code -
import os
import sys
import glob
import re
import fnmatch
import Image as im
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import scipy as sp
import scipy.stats

class LCRBrowser():

Permits to visualize log chromaticity ratios and related things for
analysing static images taken at throughout a period of time

def __init__(self, data):
# Initialize instance attributes
self.lcr = np.asarray(map((lambda x: x['lcr']), data))
self.lcr_ind = np.asarray(map((lambda x: x['lcr_ind']), data))
self.img = np.asarray(map((lambda x: x['img']), data))
self.lastind = 0
# Initial drawing and picking init
self.fig = plt.figure()
self.ax1 = self.fig.add_subplot(311)
self.ax2 = self.fig.add_subplot(312)
self.ax3 = self.fig.add_subplot(313)
self.plot1, = self.ax1.plot(self.lcr, 'o', picker=5)
self.selected, = self.ax1.plot([self.lcr[0]], 'o', ms=12, alpha=0.4,
  color='yellow', visible=False)
self.img2 = self.ax2.imshow(self.img[0], visible=True, picker=2,\
interpolation='nearest')
self.plot3, = self.ax3.plot(self.lcr_ind[0][:], 'o', visible=True, 
picker=5)
print type(self.plot3)
self.fig.canvas.mpl_connect('pick_event', self.onpick)
self.fig.canvas.draw()

def onpick(self, event):
x2 = event.mouseevent.ydata
if event.artist == self.plot1:
print 'plot1\n'
N = len(event.ind)
if not N: return True
distances = x2-self.lcr[event.ind]
indmin = distances.argmin()
dataind = event.ind[indmin]
self.lastind = dataind
elif event.artist == self.img2:
print 'img2\n'
elif event.artist == self.plot3:
print 'plot3\n'
else:
print 'didn\'t detect artist'
print str(event.artist)
return True
self.update()

def update(self):
if self.lastind is None: return

ind = self.lastind
self.img2.set_data(self.img[ind])
a = self.lcr_ind[ind][:]
self.plot3.set_data((range(len(a)), a))
self.fig.canvas.draw()

def main():
results = []
for name in range(5):

img = np.random.rand(5,4,3)
lcr = sp.stats.gmean(np.mean(np.mean(img, 0), 0))
lcr_ind = sp.stats.gmean(img, 2).reshape(-1,1)
result = {'lcr': lcr, 'lcr_ind':lcr_ind, 'img':img}
results.append(result)

LCRBrowser(results)

if __name__ == '__main__':
main()

- code end -



  

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Ensure vertical lines start from x-axis

2009-05-25 Thread collern2

I'm trying to have the points start from the x-axis (similar to a histogram)
and draw lines upwards. I've attached an image of the program output, as you
can see - there are no red lines from 0-200 on the y-axis. Any ideas how to
start them from zero?

http://www.nabble.com/file/p23707480/image.png 

Sample value from list entry for time[]
693596.03
Sample value from list entry for latency[]
1043

#
Sample Code
#


def plot_graph():

# Plotting the graph
plt.plot(time[5300:],latency[5300:], 'r-', linewidth=0.15)

# Define the axes
y_label = [0, 200, 400, 600, 800, 1000, 1200]
plt.axes().set_xlim(xmin=datetime.datetime(1900,1,1,0,0,0,0),
xmax=time[-1])
plt.axes().set_ylim(ymin=0, ymax=1400)
plt.axes().set_xticklabels(time, fontdict=None, minor=False, size=10)
plt.axes().set_yticklabels(y_label, fontdict=None, minor=False, size=10)

# Labeling the graph
ax = p.subplot(111)
ax.xaxis.set_major_locator(MaxNLocator(7))
plt.gca().xaxis.set_major_formatter(DateFormatter('%M:%S'))
plt.xlabel(x_axis)
plt.ylabel(y_axis)
plt.title(title)

# Grid
plt.grid(True)
plt.grid(alpha=0.1, color='black', linestyle='-', linewidth=0.1)
plt.savefig(figure)

# plot the graph
plot_graph()
-- 
View this message in context: 
http://www.nabble.com/Ensure-vertical-lines-start-from-x-axis-tp23707480p23707480.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] pb with figure + colormap

2009-05-25 Thread Jean-Christophe Penalva




  
Hello,
 


 

  i draw some rectangle (with PolyCollection) on one figure. I'd like to 
put
 

around (on the right vertical, or at the bottom horizontal) a colormap with 
the
 

min and max values (as 
in
 

http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html)
 


 

  Here is a part of my 
code
 


 

...
 

c = 
collections.PolyCollection(list_rect)
 

c.set_array(liste_colormap)
 

c.set_cmap(cm.hot)
 

fig = plt.figure(figsize=(16, 
12))
 

ax = 
fig.add_subplot(111)
 

ax.add_collection(c)
 

ax.set_xlim(xorig, 
xmax)
 

ax.set_ylim(yorig, 
ymax)
 

ax.set_yticks((ymax/6, (ymax/6)*3, 
(ymax/6)*5))
 

ax.set_yticklabels(('Rangee 1', 'Rangee 2','Rangee 
3'))
 

plt.title(str(num_semaine)+-+str(annee))
 

cmap=cmap,norm=norm,orientation='horizontal')
 

plt.colorbar(cax=c, 
ax=ax)
 

plt.plot()
 

plt.savefig(s+str(num_semaine)+-+str(annee)+.png)
 


 

  At the end, there's a message 
:
 

Traceback (most recent call 
last):
 

  File /.../graph4.1.2.py, line 260, in 
module
 

    plt.colorbar(cax=c, 
ax=ax)
 

  File /usr/lib/python2.6/dist-packages/matplotlib/pyplot.py, 
line 1326, 
in
 

colorbar
 

    ret = gcf().colorbar(mappable, cax = cax, ax=ax, 
**kw)
 

  File /usr/lib/python2.6/dist-packages/matplotlib/figure.py, 
line 1002, 
in
 

colorbar
 

    
cax.hold(True)
 

AttributeError: 'PolyCollection' object has no attribute 
'hold'
 


 

  Any idea 
??
 


 

  Thank 
you.
 


 

## 

 

Jean-Christophe Penalva 

 

Centre Informatique National de l'Enseignement Superieur (CINES) 

 

Montpellier, 
FRANCE
 

Tel : 33 4 67 141 414    Fax : 33 4 67 523 
763
 

http://www.cines.fr/
 






--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com ___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Ensure vertical lines start from x-axis

2009-05-25 Thread John Hunter
On Mon, May 25, 2009 at 9:02 AM, collern2 noel.colle...@gmail.com wrote:

 I'm trying to have the points start from the x-axis (similar to a histogram)
 and draw lines upwards. I've attached an image of the program output, as you
 can see - there are no red lines from 0-200 on the y-axis. Any ideas how to
 start them from zero?

 http://www.nabble.com/file/p23707480/image.png

 Sample value from list entry for time[]
 693596.03
 Sample value from list entry for latency[]
 1043

 #
 Sample Code
 #


 def plot_graph():

 # Plotting the graph
    plt.plot(time[5300:],latency[5300:], 'r-', linewidth=0.15)

It sounds like you want vlines

  http://matplotlib.sourceforge.net/search.html?q=codex+vlines
  
http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.vlines

Eg,

  plt.vlines(time[5300:], 0, latenc[5300:], color='red', lw=0.15)

JDH

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pb with figure + colormap

2009-05-25 Thread Eric Firing
Jean-Christophe Penalva wrote:
 Hello,
 
  i draw some rectangle (with PolyCollection) on one figure. I'd like to put
 around (on the right vertical, or at the bottom horizontal) a colormap 
 with the
 min and max values (as in
 http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html)
  
 
 
  Here is a part of my code
 
 ...
 c = collections.PolyCollection(list_rect)
 c.set_array(liste_colormap)
 c.set_cmap(cm.hot)

c is a PolyCollection instance

 fig = plt.figure(figsize=(16, 12))
 ax = fig.add_subplot(111)
 ax.add_collection(c)
 ax.set_xlim(xorig, xmax)
 ax.set_ylim(yorig, ymax)
 ax.set_yticks((ymax/6, (ymax/6)*3, (ymax/6)*5))
 ax.set_yticklabels(('Rangee 1', 'Rangee 2','Rangee 3'))
 plt.title(str(num_semaine)+-+str(annee))
 cmap=cmap,norm=norm,orientation='horizontal')
 plt.colorbar(cax=c, ax=ax)

but cax is looking for an axes instance in which to draw the colorbar. 
Try omitting that kwarg.  The colorbar axes will be made automatically.

Eric

 plt.plot()
 plt.savefig(s+str(num_semaine)+-+str(annee)+.png)
 
  At the end, there's a message :
 Traceback (most recent call last):
  File /.../graph4.1.2.py, line 260, in module
plt.colorbar(cax=c, ax=ax)
  File /usr/lib/python2.6/dist-packages/matplotlib/pyplot.py, line 
 1326, in
 colorbar
ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
  File /usr/lib/python2.6/dist-packages/matplotlib/figure.py, line 
 1002, in
 colorbar
 cax.hold(True)
 AttributeError: 'PolyCollection' object has no attribute 'hold'
 
  Any idea ??
 
  Thank you.
 
 ##
 Jean-Christophe Penalva
 Centre Informatique National de l'Enseignement Superieur (CINES)
 Montpellier, FRANCE
 Tel : 33 4 67 141 414Fax : 33 4 67 523 763
 http://www.cines.fr/
 
 
 
 
 --
 Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
 is a gathering of tech-side developers  brand creativity professionals. Meet
 the minds behind Google Creative Lab, Visual Complexity, Processing,  
 iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
 Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
 
 
 
 
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] saving png under XP crashes ...

2009-05-25 Thread Esmail
Hi all,

I'm new to pylab/matplotlib, so perhaps I am making a mistake here,
but when I try to save a plot under Windows as a png file, the program
crashes (pdf works fine).

This is the short script I am running:

-

import pylab as plt

plt.grid(True)

# plot a point
x = 1.5
y = 0.7
plt.plot([x], [y], 'ro')

plt.show()
#plt.savefig('plot_point2.pdf')
plt.savefig('plot_point2.png')

--

Win XP Prof, SP 2. Downloaded maptplotlib 0.98.5.3 today along with
numpy 1.3.0 (running Python 2.6.1).

Can someone else reproduce this problem? Is this a known problem?

Thanks,
Esmail


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Ensure vertical lines start from x-axis

2009-05-25 Thread Alan G Isaac
What is the right way to produce date-range bars,
like the recession bars in
http://research.stlouisfed.org/fred2/series/TB3MS?cid=116

Thanks,
Alan Isaac

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Picking and events question

2009-05-25 Thread John Hunter
On Mon, May 25, 2009 at 7:16 AM,  jorgesmbox...@yahoo.es wrote:


 Hi,
 I am trying to use matplotlib to visually explore some data. I started
 from the event_handling example code: data_browser.py example, but
 wanted to go a bit further. The idea is to have two plots and an image
 linked together. The first plot represents a measure calculated from
 an image region at different times of the day. Selecting one of this
 measures shows the corresponding image, and some other measure calculated
 from the individual pixels. Further on, selecting in the image or the
 second plot should highlight the corresponding point in the plot or pixel
 on the image, respectively (That is, the first plot is linked to the image,
 and the image and the second plot are linked together).
 My problem is that on the function being called upon and event, I always
 get events generated by the image, even when the moused was clicked on one of
 the other plots. The plots behave ok.
 The coded below is a simplified functional version (the measures here are
 trivial, and I haven't included the actions when the user selects the image or
 the second plot), which exhibits this behavior. What I see when executing this
 code is for example:


It looks like you found a pretty significant bug -- the Artist.pick
method forwards the event to all of it's children, whether or not the
pick event happened in the same Axes as the event being queried.  Not
only is this inefficient, it can create false positives when the two
axes share a similar coord system.  I just committed a fix to svn, to
make sure the artist axes instance is the same as the pick event
inaxes attribute before forwarding on the call.  artist.Artist.pick
now reads:

# Pick children
for a in self.get_children():
# make sure the event happened in the same axes
ax = getattr(a, 'axes', None)
if mouseevent.inaxes==ax:
a.pick(mouseevent)

This seems to fix the problem you identified -- give svn r7141 or
later a test drive if you have access

  http://matplotlib.sourceforge.net/faq/installing_faq.html#install-from-svn

JDH

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Ensure vertical lines start from x-axis

2009-05-25 Thread John Hunter
On Mon, May 25, 2009 at 12:35 PM, Alan G Isaac alan.is...@gmail.com wrote:
 What is the right way to produce date-range bars,
 like the recession bars in
 http://research.stlouisfed.org/fred2/series/TB3MS?cid=116


axvspan.  See

  
http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.axvspan
  http://matplotlib.sourceforge.net/examples/pylab_examples/axhspan_demo.html

JDH

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] saving png under XP crashes ...

2009-05-25 Thread John Hunter
On Mon, May 25, 2009 at 12:32 PM, Esmail ebo...@hotmail.com wrote:
 Hi all,

 I'm new to pylab/matplotlib, so perhaps I am making a mistake here,
 but when I try to save a plot under Windows as a png file, the program
 crashes (pdf works fine).


I don't have a windows box to test on today (I can try tomorrow from
work). Most likely, you have a problem of an install over an old
install.  Try installing mpl and numpy cleanly by removing all the
numpy* and matplotlib* files from your site-packages dir and
reinstalling.  See also

http://matplotlib.sourceforge.net/faq/troubleshooting_faq.html#matplotlib-install-location
http://matplotlib.sourceforge.net/faq/installing_faq.html#cleanly-rebuild-and-reinstall-everything

JDH

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] saving png under XP crashes ...

2009-05-25 Thread Esmail
Hello John,

\John Hunter wrote:
 On Mon, May 25, 2009 at 12:32 PM, Esmail ebo...@hotmail.com wrote:
 Hi all,

 I'm new to pylab/matplotlib, so perhaps I am making a mistake here,
 but when I try to save a plot under Windows as a png file, the program
 crashes (pdf works fine).

 
 I don't have a windows box to test on today (I can try tomorrow from
 work). 

That would be helpful.

 Most likely, you have a problem of an install over an old
 install.  Try installing mpl and numpy cleanly by removing all the
 numpy* and matplotlib* files from your site-packages dir and
 reinstalling.  

I didnt' have either of those packages installed before, so that
should not be a problem, but I will take a look at the links you
sent.

Thanks .. it'll be interesting to see if the problem can be
reproduced.

Esmail


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] saving png under XP crashes ...

2009-05-25 Thread John Hunter
On Mon, May 25, 2009 at 1:01 PM, Esmail ebo...@hotmail.com wrote:
 Hello John,

 \John Hunter wrote:
 On Mon, May 25, 2009 at 12:32 PM, Esmail ebo...@hotmail.com wrote:
 Hi all,

 I'm new to pylab/matplotlib, so perhaps I am making a mistake here,
 but when I try to save a plot under Windows as a png file, the program
 crashes (pdf works fine).


 I don't have a windows box to test on today (I can try tomorrow from
 work).

 That would be helpful.

 Most likely, you have a problem of an install over an old
 install.  Try installing mpl and numpy cleanly by removing all the
 numpy* and matplotlib* files from your site-packages dir and
 reinstalling.

 I didnt' have either of those packages installed before, so that
 should not be a problem, but I will take a look at the links you
 sent.

 Thanks .. it'll be interesting to see if the problem can be
 reproduced.


One thing I just noticed -- you call show before savefig.  show is
supposed to be the last line in your script, and should only be called
once.  Does moving it to the end help?

JDH

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] saving png under XP crashes ...

2009-05-25 Thread Esmail
Hi again,

John Hunter wrote:
 
 One thing I just noticed -- you call show before savefig.   show is
 supposed to be the last line in your script, and should only be called
 once.  Does moving it to the end help?

No, that's just an artifact of my trying a number of things :-)

for the pdf file save it makes no difference (but I tried both ways).

In the case of the png it always crashes, though it does create a zero-byte
file with the correct name.

Esmail


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Colorbar Ticks

2009-05-25 Thread marcusantonius

Hello,

I have the problem, that sometimes the first and last ticklabel of a
colorbar is not drawn. E.g. if I create a colorbar through
fig.colorbar(p3,orientation='horizontal',ticks=np.arange(0.0,8,2))
I only get ticklabels at 2,4,6, but I would like it to have 0,2,4,6,8 and I
don't know how to control this behaviour. If I do
cb=fig.colorbar(p3,orientation='horizontal',ticks=np.arange(0.0,8,2))
cb.ax.xaxis.set_ticks(np.arange(0,8,2))
the colorbar vanishes and instead I have 4 ticks with the labels
0.8,1.6,2.4,3.2

Thank you for your help,
Markus


-- 
View this message in context: 
http://www.nabble.com/Colorbar-Ticks-tp23712716p23712716.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar Ticks

2009-05-25 Thread marcusantonius

I should perhaps mention, that if i try
cbar=fig.colorbar(p1,orientation='horizontal',ticks=[0.0,2.0,4.0,6.0,8.0])
cbar.ax.set_xticklabels(['0', '2', '4','6','8'])
the colorbar is drawn correctly, but I get the label 0 at position 2, the
label 2 at position 4 and 4 at pos. 6, the labels at the end are not
drawn...

-- 
View this message in context: 
http://www.nabble.com/Colorbar-Ticks-tp23712716p23712944.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar Ticks

2009-05-25 Thread Eric Firing
marcusantonius wrote:
 Hello,
 
 I have the problem, that sometimes the first and last ticklabel of a
 colorbar is not drawn. E.g. if I create a colorbar through
 fig.colorbar(p3,orientation='horizontal',ticks=np.arange(0.0,8,2))
 I only get ticklabels at 2,4,6, but I would like it to have 0,2,4,6,8 and I
 don't know how to control this behaviour. If I do
 cb=fig.colorbar(p3,orientation='horizontal',ticks=np.arange(0.0,8,2))
 cb.ax.xaxis.set_ticks(np.arange(0,8,2))
 the colorbar vanishes and instead I have 4 ticks with the labels
 0.8,1.6,2.4,3.2
 
 Thank you for your help,
 Markus
 
 

Markus,

The problem here is not the specification of the ticks, it is the actual 
range of the colorbar, which is taken from the norm object used in the 
color mapping.  Try this (in ipython -pylab):

imshow(rand(10,10)*8, vmin=0, vmax=8)
colorbar(ticks=[0,2,4,6,8])

Alternatively, you can use the set_clim() method on any Mappable such as 
an image, or the pyplot clim() function, to set the limits.

Note also that to get the sequence [0,2,4,6,8] you need arange(0,9,2), 
not arange(0,8,2).  Or you can use linspace(0,8,5) if you prefer.

Eric



--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar Ticks

2009-05-25 Thread Eric Firing
marcusantonius wrote:
 I should perhaps mention, that if i try
 cbar=fig.colorbar(p1,orientation='horizontal',ticks=[0.0,2.0,4.0,6.0,8.0])

The ticks that it uses are taken from the list--they are the ones that 
are within the range of numbers mapped to colors.  The list of ticks 
does not set that range.

 cbar.ax.set_xticklabels(['0', '2', '4','6','8'])
Setting ticklabels is dangerous unless you do it based on first getting 
the actual ticks and using their values, or if you are otherwise sure of 
their values.  But it should be very rare that you have to do this.

 the colorbar is drawn correctly, but I get the label 0 at position 2, the
 label 2 at position 4 and 4 at pos. 6, the labels at the end are not
 drawn...

None of the labels correspond to their ticks in this case.

Eric




--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colorbar Ticks

2009-05-25 Thread marcusantonius

Thank you very much for your email.

Your example
imshow(rand(10,10)*8, vmin=0, vmax=8)
colorbar(ticks=[0,2,4,6,8])
works fine.

Note also that to get the sequence [0,2,4,6,8] you need arange(0,9,2), 
not arange(0,8,2).  Or you can use linspace(0,8,5) if you prefer.
Thank you for making me aware of that (You see that I don't have a lot of
experience in python and matplotlib).

I now specified the color range via vmin and vmax, and this solved my
problem. Thanks for the fast help

-- 
View this message in context: 
http://www.nabble.com/Colorbar-Ticks-tp23712716p23713404.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Ensure vertical lines start from x-axis

2009-05-25 Thread Alan G Isaac
 On Mon, May 25, 2009 at 12:35 PM, Alan G Isaac alan.is...@gmail.com wrote:
 What is the right way to produce date-range bars,
 like the recession bars in
 http://research.stlouisfed.org/fred2/series/TB3MS?cid=116



On 5/25/2009 1:45 PM John Hunter apparently wrote:
 axvspan.  See
 
   
 http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.axvspan
   http://matplotlib.sourceforge.net/examples/pylab_examples/axhspan_demo.html


Great!
Thanks,
Alan

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] saving png under XP crashes ...

2009-05-25 Thread Christoph Gohlke
Hi,

I can confirm the crash of python.exe when saving PNG files using 
matplotlib 0.98.5.3 under Python 2.5.4 and 2.6.2 (32 bit binaries from 
python.org) on Windows Vista 64 bit. Saving to a PDF file works. The 
crash occurs in _png.write_png(). When replacing the file _png.pyd with 
version 0.98.5.2 saving of PNG files works. There were no changes in the 
write_png function since 0.98.5.2.

import matplotlib
matplotlib.use('Agg')
from matplotlib import pylab
pylab.plot([0], [0])
pylab.savefig(test.png) # crashes here
pylab.close()

Thanks,

Christoph

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Picking and events question

2009-05-25 Thread jorgesmbox-ml


 It looks like you found a pretty significant bug -- the Artist.pick
 method forwards the event to all of it's children, whether or not the
 pick event happened in the same Axes as the event being queried.  Not
 only is this inefficient, it can create false positives when the two
 axes share a similar coord system.  I just committed a fix to svn, to
 make sure the artist axes instance is the same as the pick event
 inaxes attribute before forwarding on the call.  artist.Artist.pick
 now reads:
 
 # Pick children
 for a in self.get_children():
 # make sure the event happened in the same axes
 ax = getattr(a, 'axes', None)
 if mouseevent.inaxes==ax:
 a.pick(mouseevent)
 
 This seems to fix the problem you identified -- give svn r7141 or
 later a test drive if you have access
 
   http://matplotlib.sourceforge.net/faq/installing_faq.html#install-from-svn
 
 JDH

Thanks! Your solution works for me. I haven't actually tested the svn, only 
patched the current version provided by my distribution (0.98.5.2) with the 
modification you posted.

Jorges


  

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users