[Matplotlib-users] cmap normalization question

2011-10-31 Thread Tommy Grav
Hi,

   I have been looking around but can't find what I want.
I have two arrays, one with numbers from 0.02 to 0.20 and
the other from 0.03 to 0.50. I am trying to plot them together
with other arrays in a scatterplot where these two are the
color term

plt.scatter(x1,y1,c=myarr1,cmap=plt.get_cmap("gist_heat))
plt.scatter(x2,y2,c=myarr2,cmap=plt.get_cmap("gist_heat))

but it seems that each instance of the plot command rescales
the array such that myarr1.max() and myarr2.max() are both with,
which means that the two color scales are out of sync. Is there
a way to force the two plots to respect the values in the array
have the cmap go from 0 to 1, not from myarr1.min() to myarr1.max()?

Cheers
  Tommy

--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] cmap normalization question

2011-10-31 Thread Benjamin Root
On Mon, Oct 31, 2011 at 11:02 AM, Tommy Grav  wrote:

> Hi,
>
>   I have been looking around but can't find what I want.
> I have two arrays, one with numbers from 0.02 to 0.20 and
> the other from 0.03 to 0.50. I am trying to plot them together
> with other arrays in a scatterplot where these two are the
> color term
>
> plt.scatter(x1,y1,c=myarr1,cmap=plt.get_cmap("gist_heat))
> plt.scatter(x2,y2,c=myarr2,cmap=plt.get_cmap("gist_heat))
>
> but it seems that each instance of the plot command rescales
> the array such that myarr1.max() and myarr2.max() are both with,
> which means that the two color scales are out of sync. Is there
> a way to force the two plots to respect the values in the array
> have the cmap go from 0 to 1, not from myarr1.min() to myarr1.max()?
>
> Cheers
>  Tommy
>
>
Tommy,

The general method is to use a Normalize object and pass it as kwarg
'norm'.  However, as a convenience, some plotting functions has a 'vmin'
and 'vmax' kwarg that can be specified:

plt.scatter(x1,y1,c=myarr1,cmap=plt.get_cmap("gist_heat), vmin=0.0,
vmax=1.0)
plt.scatter(x2,y2,c=myarr2,cmap=plt.get_cmap("gist_heat), vmin=0.0,
vmax=1.0)

Cheers!
Ben Root
--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] cmap normalization question

2011-10-31 Thread Daniel Hyams
Try

nm = matplotlib.colors.Normalize(desired_min, desired_max)

plt.scatter(x1,y1,c=myarr1,cmap=plt.get_cmap("gist_heat"),norm=nm)

You could just use the vmin/vmax keywords in the scatter() call, but
I've just always preferred using Normalize(); you have more control
over what happens that way (see docs for Normalize).

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

On Mon, Oct 31, 2011 at 12:02 PM, Tommy Grav  wrote:
> Hi,
>
>   I have been looking around but can't find what I want.
> I have two arrays, one with numbers from 0.02 to 0.20 and
> the other from 0.03 to 0.50. I am trying to plot them together
> with other arrays in a scatterplot where these two are the
> color term
>
> plt.scatter(x1,y1,c=myarr1,cmap=plt.get_cmap("gist_heat))
> plt.scatter(x2,y2,c=myarr2,cmap=plt.get_cmap("gist_heat))
>
> but it seems that each instance of the plot command rescales
> the array such that myarr1.max() and myarr2.max() are both with,
> which means that the two color scales are out of sync. Is there
> a way to force the two plots to respect the values in the array
> have the cmap go from 0 to 1, not from myarr1.min() to myarr1.max()?
>
> Cheers
>  Tommy
>
> --
> Get your Android app more play: Bring it to the BlackBerry PlayBook
> in minutes. BlackBerry App World™ now supports Android™ Apps
> for the BlackBerry® PlayBook™. Discover just how easy and simple
> it is! http://p.sf.net/sfu/android-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Daniel Hyams
dhy...@gmail.com

--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Custom tick labels for mplot3D

2011-10-31 Thread Katie Boyle
Hi All,

I was wondering how to set custom tick labels in an mplot3D plot? I have
tried:

ax = Axes3D(figure)
ax.set_xticks(ticks,labels)

- and -

ax = Axes3D(figure)
ax.w_xaxis.set_ticks(ticks,labels)

and both options cause the plot to disappear from the viewing window.

When I don't try to set ticks, the window shows up fine except for the fact
that it displays the axis values -120.1, -120.5, -120.7 as -0.1, -0.5,
-0.7, which isn't going to work for me. I need a way to force the plot to
display the values exactly as they are written.

Many thanks in advance,

Katie
--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Issues with Cursor change using glade-3 and Matplotlib

2011-10-31 Thread Atma Kanojia

Hi All,

I am new to matplotlib and glade and am struggling with changing cursors in a glade-3 based python application using matplotlib. I have attached the simple 
application plot_in_Glade.py and plot_in_Glade.glade.  I am trying to change the cursor on the plot but unfortunately no luck (gives no error though). 
(line 31 in plot_in_Glade.py) I have attached a simpleTest.py in which I am able to change the cursor (pretty much the same code for plotting except no 
glade for UI)


Version:
glade 3.6.7
python 2.6.6 on RHEL6

I know this is not the correct forum to ask about glade issues but on a different note I am not sure if any of you have encountered the problem of dialog 
boxes being modal even though they are set for being non-modal. In my attached application I have made the 1st dialog box non-modal (which is being called 
by testMain) and the plot dialog box as non-modal but in both cases I cannot access the parent dialog box once the child is spawned ! Any ideas ?


Looking forward to hearing from you.

Regards
Atma
#!/usr/bin/env python
import sys
import os
from math import *
from numpy import *
import string
import matplotlib.pyplot as plt
from matplotlib.widgets import Cursor

class SimpleTest:

def __init__(self):
pass

def TestMe(self):
fig = plt.figure(figsize=(23,18), dpi = 70)
ax = fig.add_axes([0.09,0.05,0.9,0.9]) # [left, bottom, width, 
height]
ax.set_xlabel('Time (sec)')
ax.set_ylabel('voltage')
ax.set_title('Simple Test')
ax.plot(arange(0.0,3.0,0.01), sin(2*pi*arange(0.0,3.0,0.01)))
plt.grid(True)
#ax.axis([0, timeBase[self.totalFaults-1]+0.05, 0, 72])
cursor = Cursor(ax, useblit=True, color='red', linestyle = 
'dashed', linewidth=1)
plt.show()

# read data from cps_raw
a = SimpleTest()
a.TestMe()
del a
sys.exit(0)


  
  
  
200
200
True

  
200
200
True

  
Pop Up
True
True
True

  
  
0
  


  
Quit
True
True
True

  
  
1
  

  

  
  
200
200
5
center
True
normal
False

  
200
200
True
vertical
2

  
Plot
True
True
True

  
  
1
  


  
True
end

  


  

  
  
False
end
0
  

  

  
  
True
5
True
normal
False

  
True
vertical
2

  
True
vertical

  

  
  
1
  


  
True
end

  


  
gtk-quit
True
True
True
True
  
  
False
False
1
  

  
  
False
end
0
  

  

  

#!/usr/bin/env python
import matplotlib
matplotlib.use('GTK')

import matplotlib.pyplot as plt
from matplotlib.widgets import Cursor
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as 
FigureCanvas
from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as 
NavigationToolbar
from numpy import arange, sin, pi
import gtk
import gtk.glade

class WidgetsWrapper:
def __init__(self):

self.gladefile="plot_in_Glade.glade"
#self.wTree = gtk.glade.XML(self.gladefile, "dlgTest")
self.widgets = gtk.glade.XML(self.gladefile, "dlgTest")
dic = { "on_button1_clicked" : self.Buttn1}

self.widgets.signal_autoconnect(dic)
self.fig = plt.figure(figsize=(23,18), dpi=72)
self.ax = self.fig.add_axes([0.09,0.05,0.9,0.9]) # [left, bottom, 
width, height]

t = arange(0.0,3.0,0.01)
s = sin(2*pi*t)
self.ax.plot(t,s)
self.ax.set_xlabel('time (s)')
self.ax.set_ylabel('voltage')
self.ax.grid(True)
cursor = Cursor(self.ax, useblit=True, color='red', linestyle = 
'dashed', linewidth=1)
self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea
self.canvas.show()
self.canvas.set_size_request(1580, 1100)
self.canvas.set_flags(gtk.HAS_FOCUS|gtk.CAN_FOCUS)
 

Re: [Matplotlib-users] Custom tick labels for mplot3D

2011-10-31 Thread Benjamin Root
On Monday, October 31, 2011, Katie Boyle  wrote:
> Hi All,
> I was wondering how to set custom tick labels in an mplot3D plot? I have
tried:
> ax = Axes3D(figure)
> ax.set_xticks(ticks,labels)
> - and -
> ax = Axes3D(figure)
> ax.w_xaxis.set_ticks(ticks,labels)
> and both options cause the plot to disappear from the viewing window.
> When I don't try to set ticks, the window shows up fine except for the
fact that it displays the axis values -120.1, -120.5, -120.7 as -0.1, -0.5,
-0.7, which isn't going to work for me. I need a way to force the plot to
display the values exactly as they are written.
> Many thanks in advance,
> Katie


Which version of mpl are you using?  Note that there have been *huge*
advances in usability for the recently released v1.1.0.  Many of the same
functions you would normally use in regular plots are now available for
mplot3d, and the need to use w_xaxis and such is going away.

Ben Root
--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users