Re: [Matplotlib-users] TclError Couldn't Connect to display :0.0

2009-02-25 Thread rlp_GMC

Here is some additional  information regarding this problem

OS -- Linux 2.6.22-16-generic #1 SMP Mon Jan 26 00:07:52 GMT 2009 i686
GNU/Linux

Moved matplotlibrc to  os.environ['HOME'] =  '/tmp/matlibconfig' because
of write permission problems with apache child processes. 

No customizations to matplotlibrc

Ubuntu Gutsy

Python-matplotlib   0.90.1-2ubuntu1
Python-matplotlib-data  0.90.1-2ubuntu1
Python-matplotlib-doc   0.90.1-2ubuntu1


Code 
# This code is called by another python script
# and I am not even using the parameters that 
# are passed
# Code works from python idle

import sys, math
import matplotlib_config_path # this sets configpath as described above

import matplotlib 
matplotlib.use('Agg') # use non gui backend

from matplotlib import pylab as plt
import numpy as np
import os,sys 

def VT(batt_v, batt_temp0, batt_temp1, batt_ts, plotfile, dur):  

t =[]  

for x in batt_ts:# time axis to 0 based
t.append((x - batt_ts[0])/divsor[dur]) 

fig = plt.figure()
ax1 = fig.add_subplot(111)   # subplot 1 col x 1 row   

ax1.plot([1,2,3])
fig.savefig('test.png')

Error returned is the same


rlp_GMC wrote:
 
 When I try to save a fig to a file  I get the error 
 
 TclError Couldn't Connect to display :0.0  
 
 I looked in the Maplotlib users manual  (latest version pg 144-146)  and
 tried the following with no luck. BTW why is the same module named
 differently Linux/Win ?
 
 import matplotlib
 matplotlib.use('Agg')
 import matplotlib.pylab as plt (linux )   or,  import matplotlib.pyplot as
 plt   (Windows)
 fig = plt.figure()
 ax = fig.add_subplot(111)
 ax.plot([1,2,3])
 fig.savefig('test.png')
 
 Is Matplotlib trying to display a plot to the monitor? 
 
 rlp
 


-- 
View this message in context: 
http://www.nabble.com/TclError-Couldn%27t-Connect-to-display-%22%3A0.0%22-tp22176192p22207062.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Mathtext + stixsans weird baseline

2009-02-25 Thread Ryan May
Hi,

When I combine mathtext with the stixsans fonts while mathtext.default is
set to 'regular', horizontal text is not vertically aligned properly, like
the baseline is moving.  I've attached an image of what I see when I run the
following code.  It should be noted that I don't see anything like this on
the vertical axis, and it all goes away if I stop using mathtext.

import matplotlib.pyplot as plt
from matplotlib import rcParams
rcParams['font.size'] = 12.0
rcParams['mathtext.default'] = 'regular'
rcParams['mathtext.fontset'] = 'stixsans'

fig = plt.figure()

plt.xlabel('ItLooksToMeLikeTheBaselineMoves $(g m^{-3})$')
plt.ylabel('ItLooksToMeLikeTheBaselineMoves $(db km^{-1})$')
plt.show()


Thoughts? Am I doing something bad?  Can anyone else reproduce this?

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from: Norman Oklahoma United States.
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Mathtext + stixsans weird baseline

2009-02-25 Thread Ryan May
And here's the image I promised.

On Wed, Feb 25, 2009 at 3:13 PM, Ryan May rma...@gmail.com wrote:

 Hi,

 When I combine mathtext with the stixsans fonts while mathtext.default is
 set to 'regular', horizontal text is not vertically aligned properly, like
 the baseline is moving.  I've attached an image of what I see when I run the
 following code.  It should be noted that I don't see anything like this on
 the vertical axis, and it all goes away if I stop using mathtext.

 import matplotlib.pyplot as plt
 from matplotlib import rcParams
 rcParams['font.size'] = 12.0
 rcParams['mathtext.default'] = 'regular'
 rcParams['mathtext.fontset'] = 'stixsans'

 fig = plt.figure()

 plt.xlabel('ItLooksToMeLikeTheBaselineMoves $(g m^{-3})$')
 plt.ylabel('ItLooksToMeLikeTheBaselineMoves $(db km^{-1})$')
 plt.show()


 Thoughts? Am I doing something bad?  Can anyone else reproduce this?

 Ryan

 --
 Ryan May
 Graduate Research Assistant
 School of Meteorology
 University of Oklahoma
 Sent from: Norman Oklahoma United States.




-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from: Norman Oklahoma United States.
attachment: weird_font.png--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] numerix is deprecated

2009-02-25 Thread Eric Firing
If you have any intention of continuing to install updated versions of 
matplotlib as they come along, then please start now to eliminate the 
use of the matplotlib.numerix subpackage, if you have not already done 
so.  It has not been used internally in matplotlib, or made available 
via pylab, for well over a year.

In the next release of matplotlib based on the svn trunk, importing 
numerix will trigger a warning.  In some later release, numerix will be 
removed entirely.

Note that the sole present function of numerix is essentially to make 
numpy behave like the old Numeric.

Eric

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Help with simply plotting 2d array, please

2009-02-25 Thread lionel keene
Hello all, I've been trying for days but I can't seem to get the
result I'm looking for. I have a 2d array of type numpy.ndarray
which I'd like to plot as a simple color map.  I'd like to plot it in
the upper-lefthand corner of the client area in a wxPython frame. The
plotting needs to be a very simple 1:1 ratio, for example if the numpy
array has 400 rows and 500 columns, I would like to plot it so that it
assumes 400x500 pixels in the wxPython frame. I do not need axis ticks
and labels, just the colormap plot itself. I can get my figure to plot
(with tick marks and labels since I haven't figured out how to turn
those off) but I cannot size it properly. I've copied a tutorial
example I found and modify it and through tedious trial and error have
gotten half-way to where I need:


# First attempt to render data to a window:

import matplotlib
matplotlib.use('WXAgg')

from matplotlib import rcParams
import numpy

import matplotlib.cm as cm

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg


#from matplotlib.figure import Figure

from wx import *

import DataFileTypes as DFT


class DataFrame(Frame):

def __init__(self):

Frame.__init__(self, None, -1, Data filename here,
   size=DisplaySize())

def displayData(self):

data = None

# Load data into data object using my custom IntData(...) class:
try:
data = DFT.INTData(C:\SAR Test files\Tibet2008.int)

except DFT.DataFileError:
print(Error opening data file)

except DFT.ResourceFileError:
print(Error opening resource file)


if data:

# Assume a screen dpi of 96...seems very flakey to me:
ScreenDPI = 96.0


# compute the width and height of figure using this dpi
# and the rows and columns of the data for a 1:1 display ratio:
FigureWidthInInches  = (data.numcolumns / ScreenDPI)
FigureHeightInInches = (data.numrows / ScreenDPI)
print(FigureWidthInInches, FigureHeightInInches)

# Instantiate Figure based on these parameters:
self.fig =
matplotlib.figure.Figur((FigureWidthInInches,FigureHeightInInches),
dpi = ScreenDPI)
self.canvas = FigureCanvasWxAgg(self, -1, self.fig)

# Put everything into a sizer:
sizer = BoxSizer(VERTICAL)
#sizer.Add(self.canvas, 1, LEFT | TOP | GROW)
sizer.Add(self.canvas, 0, LEFT | TOP)
self.SetSizer(sizer)
# self.Fit()

a = self.fig.add_axes([0.075, 0.1, 0.75, 0.85])
self.im = a.imshow(data.getNumpyArray(),
interpolation=None, cmap = data.getCustomColorMap())




if __name__ == '__main__':

app = PySimpleApp()
frame = DataFrame()
frame.displayData()

frame.Show()
app.MainLoop()


It displays but the plot is inside the figure i.e. the colormap of the
data is within the figure that I've sized. matplotlib does this by
design, of course, but I cannot figure out how to defeat it. For one
thing, I don't think I'm sizing the figure correctly by setting
(guessing at) the dpi and computing the inches...just seems wrong, but
I can't find any tutorials or examples that show anything that sizes
figures using pixels or screen coords.

I always know the dimensions of my data a priori, so let's assume the
following very simple situation:

- I have a numpy.ndarray of data with 350 rows and 500 columns. How do
I display it in the upper-left hand corner of the frame client with no
tick marks/labels, etc...just the colormap at screen
coords(0,0)-(349,499)  (rows,columns)? Could someone post a few lines
to do this? Thanks so much in advance!

-L

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] upgrading matplotlib within EPD

2009-02-25 Thread Daniel Soto
does anyone know how to upgrade the matplotlib package that ships with  
the enthought python distribution?  the current enthought release  
matplotlib is 0.98.3 and i'd like to upgrade to 0.98.5.  i'm on an os  
x intel platform running leopard.

thank you,
daniel soto

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Matplotlib documentation

2009-02-25 Thread Gökhan SEVER
Hello,

My first message in the list. I would like to mention a few things about the
matplotlib PDF document.

Firstly, the download link for the pdf document (@
http://matplotlib.sourceforge.net/contents.html) is for release 0.98.5.1,
compiled on December 17, instead of 0.98.5.2, on Dec-18.

Next, is there a way to get functions separately listed under each bookmark
listing in the pdf file? For example if I go IV Matplotlib API section from
the bookmarks menu and click the matplotlib.pyplot seb-menu I would like to
see the function names listed. In addition to module indexing (where
keywords highlighted back to original names) this would be a nice feature to
add the pdf documentation.

If this needs a manual configuration, I am volunteering to spend time to add
this functionality.

Regards,
Gökhan SEVER
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Help with simply plotting 2d array, please

2009-02-25 Thread Tom K.



LKeene wrote:
 
 
 - I have a numpy.ndarray of data with 350 rows and 500 columns. How do
 I display it in the upper-left hand corner of the frame client with no
 tick marks/labels, etc...just the colormap at screen
 coords(0,0)-(349,499)  (rows,columns)? Could someone post a few lines
 to do this? Thanks so much in advance!
 
 -L
 

Hmm... interesting problem...

Here's a simple example where the image fills the frame - note the
properties such as xticks, yticks = [], position=[0,0,1,1], and the size of
the Frame itself... on my platform (Mac OS X) the height of the frame should
be 22 pixels more than the image (discovered by trial and error).  

The border of the axes is still visible in black - obscuring the outer
pixels of the image - does anyone know how to shut that off?

import matplotlib
matplotlib.interactive(False)
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.figure import Figure
from  matplotlib.pyplot import setp

import numpy as np

import wx

class MatplotlibFrame(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.figure = Figure()
print self.figure
self.canvas = FigureCanvasWxAgg(self, -1, self.figure)

self.subplot = self.figure.add_subplot(111)
#cdata = np.random.rand(351, 501)
cdata = np.zeros((351, 501))
cdata[::50, ::50] = 1
self.subplot.imshow(cdata, aspect='equal', interpolation='nearest')
setp(self.subplot, xticks=[], yticks=[], position=[0,0,1,1])

def repaint(self):
self.canvas.draw()


class App(wx.App):
def OnInit(self):
frame = MatplotlibFrame(parent=None, title=an image, size=(501,
351+22))
frame.Show()
return True

app = App()
app.MainLoop()


-- 
View this message in context: 
http://www.nabble.com/Help-with-simply-plotting-2d-array%2C-please-tp22214482p22216497.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Help with simply plotting 2d array, please

2009-02-25 Thread Jae-Joon Lee
I don't use wx so i'm not sure if this could be helpful, but you may
check the figimage command.

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

Note that it draws the image directly into the figure, thus no axes is needed.

-JJ



On Wed, Feb 25, 2009 at 6:09 PM, lionel keene lionel.ke...@gmail.com wrote:
 Hello all, I've been trying for days but I can't seem to get the
 result I'm looking for. I have a 2d array of type numpy.ndarray
 which I'd like to plot as a simple color map.  I'd like to plot it in
 the upper-lefthand corner of the client area in a wxPython frame. The
 plotting needs to be a very simple 1:1 ratio, for example if the numpy
 array has 400 rows and 500 columns, I would like to plot it so that it
 assumes 400x500 pixels in the wxPython frame. I do not need axis ticks
 and labels, just the colormap plot itself. I can get my figure to plot
 (with tick marks and labels since I haven't figured out how to turn
 those off) but I cannot size it properly. I've copied a tutorial
 example I found and modify it and through tedious trial and error have
 gotten half-way to where I need:


 # First attempt to render data to a window:

 import matplotlib
 matplotlib.use('WXAgg')

 from matplotlib import rcParams
 import numpy

 import matplotlib.cm as cm

 from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg


 #from matplotlib.figure import Figure

 from wx import *

 import DataFileTypes as DFT


 class DataFrame(Frame):

    def __init__(self):

        Frame.__init__(self, None, -1, Data filename here,
                       size=DisplaySize())

    def displayData(self):

        data = None

        # Load data into data object using my custom IntData(...) class:
        try:
            data = DFT.INTData(C:\SAR Test files\Tibet2008.int)

        except DFT.DataFileError:
            print(Error opening data file)

        except DFT.ResourceFileError:
            print(Error opening resource file)


        if data:

            # Assume a screen dpi of 96...seems very flakey to me:
            ScreenDPI = 96.0


            # compute the width and height of figure using this dpi
            # and the rows and columns of the data for a 1:1 display ratio:
            FigureWidthInInches  = (data.numcolumns / ScreenDPI)
            FigureHeightInInches = (data.numrows / ScreenDPI)
            print(FigureWidthInInches, FigureHeightInInches)

            # Instantiate Figure based on these parameters:
            self.fig =
 matplotlib.figure.Figur((FigureWidthInInches,FigureHeightInInches),
 dpi = ScreenDPI)
            self.canvas = FigureCanvasWxAgg(self, -1, self.fig)

            # Put everything into a sizer:
            sizer = BoxSizer(VERTICAL)
            #sizer.Add(self.canvas, 1, LEFT | TOP | GROW)
            sizer.Add(self.canvas, 0, LEFT | TOP)
            self.SetSizer(sizer)
            # self.Fit()

            a = self.fig.add_axes([0.075, 0.1, 0.75, 0.85])
            self.im = a.imshow(data.getNumpyArray(),
 interpolation=None, cmap = data.getCustomColorMap())




 if __name__ == '__main__':

    app = PySimpleApp()
    frame = DataFrame()
    frame.displayData()

    frame.Show()
    app.MainLoop()


 It displays but the plot is inside the figure i.e. the colormap of the
 data is within the figure that I've sized. matplotlib does this by
 design, of course, but I cannot figure out how to defeat it. For one
 thing, I don't think I'm sizing the figure correctly by setting
 (guessing at) the dpi and computing the inches...just seems wrong, but
 I can't find any tutorials or examples that show anything that sizes
 figures using pixels or screen coords.

 I always know the dimensions of my data a priori, so let's assume the
 following very simple situation:

 - I have a numpy.ndarray of data with 350 rows and 500 columns. How do
 I display it in the upper-left hand corner of the frame client with no
 tick marks/labels, etc...just the colormap at screen
 coords(0,0)-(349,499)  (rows,columns)? Could someone post a few lines
 to do this? Thanks so much in advance!

 -L

 --
 Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
 -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
 -Strategies to boost innovation and cut costs with open source participation
 -Receive a $600 discount off the registration fee with the source code: SFAD
 http://p.sf.net/sfu/XcvMzF8H
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut 

[Matplotlib-users] plotting cartesian high school-style axes

2009-02-25 Thread Scott Graham

Hi

I'm trying to draw something like
http://en.wikipedia.org/wiki/File:Cartesian-coordinate-system.svg

Below is my current attempt.

Four questions:
1. The y-axis label is vertical: how do I make it horizontal?
2. How can I move the axis numbering to be in the centre of the graph,
rather than around the outside?
3. Most of the mess below is to try to get the arrow heads not to be
stretched. Is there a better way to draw those in screen space rather than
graph space?
4. The axis label positioning is ugly too, is there a better way to align
that text's midpoint?

Answers to any of these will be greatfully received. :)

Or, if I'm going about this all wrong and I missed an easy helper function,
that'd be even better!

thanks,
scott


-
from __future__ import division
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np

def cartesian(w,h):
fig = plt.figure(figsize=(5,5))
ax = plt.axes()
arrowExtraW = w/6
arrowExtraH = h/6
box = dict(edgecolor='white', facecolor='white', pad=5)

plt.xlabel($x$, bbox=box)
ax.xaxis.set_label_coords(1.03, 0.515)

plt.ylabel($y$, bbox=box)
ax.yaxis.set_label_coords(0.515, 1.03)

plt.axis([-w-arrowExtraW, w+arrowExtraW, -h-arrowExtraH, h+arrowExtraH])
plt.arrow(-w, 0, w*2, 0, head_width=arrowExtraH/1.5,
head_length=arrowExtraW, edgecolor=black,
facecolor=black, label=$x$)
plt.arrow(w, 0, -w*2, 0, head_width=arrowExtraH/1.5,
head_length=arrowExtraW, edgecolor=black, facecolor=black)
plt.arrow(0, -h, 0, h*2, head_width=arrowExtraW/1.5,
head_length=arrowExtraH, edgecolor=black,
facecolor=black, label=$y$)
plt.arrow(0, h, 0, -h*2, head_width=arrowExtraW/1.5,
head_length=arrowExtraH, edgecolor=black, facecolor=black)
plt.grid(True)
plt.savefig(a.png)

cartesian(20, 6)



-- 
View this message in context: 
http://www.nabble.com/plotting-cartesian-%22high-school%22-style-axes-tp22217764p22217764.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users