[Matplotlib-users] [ploting data] Live data

2011-12-02 Thread Fabien Lafont
Hello everyone, I'm trying to plot live data extracting from remote
devices (here it's simulated by get_info1 and 2 the result is always
0.8 or 0.9

I can't understand why it doesnt plot the graph at the end of the
while loop. Does somebody has an idea?

#!/usr/bin/env python

from visa import *
from pylab import *
import sys
from PyQt4 import QtGui
import numpy as np
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg
as NavigationToolbar

#===
#
#===

class CPUMonitor(FigureCanvas):
"""Matplotlib Figure widget"""
def __init__(self,parent):

# first image setup
self.fig = Figure()
self.ax = self.fig.add_subplot(111)
# initialization of the canvas
FigureCanvas.__init__(self, self.fig)
# set specific limits for X and Y axes
self.ax.set_xlim(0, 2)
self.ax.set_ylim(0, 1.5)


# generates first "empty" plots
self.user, self.nice = [], []
self.l_user, = self.ax.plot([], self.user, label='Voltage')
self.l_nice, = self.ax.plot([], self.nice, label='Voltage2')



self.ax.legend()

# force a redraw of the Figure
self.fig.canvas.draw()

self.principal()




def principal(self) :
stop = 0
while stop==0 :
time.sleep(1)
self.set_voltage()
time.sleep(1)
result1 = self.get_info()
result2 = self.get_info2()

#  append new data to the datasets
self.user.append(result1)
self.nice.append(result2)

self.l_user.set_data(range(len(self.user)), self.user)
self.l_nice.set_data(range(len(self.nice)), self.nice)

# force a redraw of the Figure

self.fig.canvas.draw()
FigureCanvas.updateGeometry(self)

def get_info(self):
return [0.8]

def get_info2(self) :
return [0.9]

def set_voltage(self) :
print "ok"




#===
#
#===



class ApplicationWindow(QtGui.QMainWindow):
"""Example main window"""
def __init__(self):
# initialization of Qt MainWindow widget
QtGui.QMainWindow.__init__(self)
# set window title
self.setWindowTitle("QHE manip")
# instantiate a widget, it will be the main one
self.main_widget = QtGui.QWidget(self)
# create a vertical box layout widget
vbl = QtGui.QVBoxLayout(self.main_widget)
# instantiate our Matplotlib canvas widget
qmc = CPUMonitor(self.main_widget)
# instantiate the navigation toolbar
ntb = NavigationToolbar(qmc, self.main_widget)
# pack these widget into the vertical box
vbl.addWidget(qmc)
vbl.addWidget(ntb)

# set the focus on the main widget
self.main_widget.setFocus()
# set the central widget of MainWindow to main_widget
self.setCentralWidget(self.main_widget)

# create the GUI application
qApp = QtGui.QApplication(sys.argv)
# instantiate the ApplicationWindow widget
aw = ApplicationWindow()
# show the widget
aw.show()
# start the Qt main loop execution, exiting from this script
# with the same return code of Qt application
sys.exit(qApp.exec_())

--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] problem with annotate

2011-12-02 Thread Neal Becker
Using horizontalalignment='right', it seems that if a point lies on the right 
edge of the plot, the annotation does not appear, even though (since the text 
should be right aligned), the text would have been on the plot and be visible.

Any workaround?


--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [ploting data] Live data

2011-12-02 Thread Daniel Hyams
I don't have PyQt installed, so I couldn't test the code, but don't you
want to be using "extend" and not "append", if you are returning a list
from your two get_info() functions?

On Fri, Dec 2, 2011 at 8:13 AM, Fabien Lafont wrote:

> Hello everyone, I'm trying to plot live data extracting from remote
> devices (here it's simulated by get_info1 and 2 the result is always
> 0.8 or 0.9
>
> I can't understand why it doesnt plot the graph at the end of the
> while loop. Does somebody has an idea?
>
> #!/usr/bin/env python
>
> from visa import *
> from pylab import *
> import sys
> from PyQt4 import QtGui
> import numpy as np
> from matplotlib.figure import Figure
> from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
> FigureCanvas
> from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg
> as NavigationToolbar
>
>
> #===
> #
>
> #===
>
> class CPUMonitor(FigureCanvas):
>"""Matplotlib Figure widget"""
>def __init__(self,parent):
>
># first image setup
>self.fig = Figure()
>self.ax = self.fig.add_subplot(111)
># initialization of the canvas
>FigureCanvas.__init__(self, self.fig)
># set specific limits for X and Y axes
>self.ax.set_xlim(0, 2)
>self.ax.set_ylim(0, 1.5)
>
>
># generates first "empty" plots
>self.user, self.nice = [], []
>self.l_user, = self.ax.plot([], self.user, label='Voltage')
>self.l_nice, = self.ax.plot([], self.nice, label='Voltage2')
>
>
>
>self.ax.legend()
>
># force a redraw of the Figure
>self.fig.canvas.draw()
>
>self.principal()
>
>
>
>
>def principal(self) :
>stop = 0
>while stop==0 :
>time.sleep(1)
>self.set_voltage()
>time.sleep(1)
>result1 = self.get_info()
>result2 = self.get_info2()
>
> #  append new data to the datasets
>self.user.append(result1)
>self.nice.append(result2)
>
>self.l_user.set_data(range(len(self.user)), self.user)
>self.l_nice.set_data(range(len(self.nice)), self.nice)
>
># force a redraw of the Figure
>
>self.fig.canvas.draw()
>FigureCanvas.updateGeometry(self)
>
>def get_info(self):
>return [0.8]
>
>def get_info2(self) :
>return [0.9]
>
>def set_voltage(self) :
>print "ok"
>
>
>
>
>
> #===
> #
>
> #===
>
>
>
> class ApplicationWindow(QtGui.QMainWindow):
>"""Example main window"""
>def __init__(self):
># initialization of Qt MainWindow widget
>QtGui.QMainWindow.__init__(self)
># set window title
>self.setWindowTitle("QHE manip")
># instantiate a widget, it will be the main one
>self.main_widget = QtGui.QWidget(self)
># create a vertical box layout widget
>vbl = QtGui.QVBoxLayout(self.main_widget)
># instantiate our Matplotlib canvas widget
>qmc = CPUMonitor(self.main_widget)
># instantiate the navigation toolbar
>ntb = NavigationToolbar(qmc, self.main_widget)
># pack these widget into the vertical box
>vbl.addWidget(qmc)
>vbl.addWidget(ntb)
>
># set the focus on the main widget
>self.main_widget.setFocus()
># set the central widget of MainWindow to main_widget
>self.setCentralWidget(self.main_widget)
>
> # create the GUI application
> qApp = QtGui.QApplication(sys.argv)
> # instantiate the ApplicationWindow widget
> aw = ApplicationWindow()
> # show the widget
> aw.show()
> # start the Qt main loop execution, exiting from this script
> # with the same return code of Qt application
> sys.exit(qApp.exec_())
>
>
> --
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Daniel Hyams
dhy...@gmail.com
--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-n

Re: [Matplotlib-users] [ploting data] Live data

2011-12-02 Thread Fabien Lafont
Thx Daniel I didn't know extend and it's more suitable for my program.
It doesn't change the problem of plotting, but thx again!


2011/12/2 Daniel Hyams :
> I don't have PyQt installed, so I couldn't test the code, but don't you want
> to be using "extend" and not "append", if you are returning a list from your
> two get_info() functions?
>
> On Fri, Dec 2, 2011 at 8:13 AM, Fabien Lafont 
> wrote:
>>
>> Hello everyone, I'm trying to plot live data extracting from remote
>> devices (here it's simulated by get_info1 and 2 the result is always
>> 0.8 or 0.9
>>
>> I can't understand why it doesnt plot the graph at the end of the
>> while loop. Does somebody has an idea?
>>
>> #!/usr/bin/env python
>>
>> from visa import *
>> from pylab import *
>> import sys
>> from PyQt4 import QtGui
>> import numpy as np
>> from matplotlib.figure import Figure
>> from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
>> FigureCanvas
>> from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg
>> as NavigationToolbar
>>
>>
>> #===
>> #
>>
>> #===
>>
>> class CPUMonitor(FigureCanvas):
>>    """Matplotlib Figure widget"""
>>    def __init__(self,parent):
>>
>>        # first image setup
>>        self.fig = Figure()
>>        self.ax = self.fig.add_subplot(111)
>>        # initialization of the canvas
>>        FigureCanvas.__init__(self, self.fig)
>>        # set specific limits for X and Y axes
>>        self.ax.set_xlim(0, 2)
>>        self.ax.set_ylim(0, 1.5)
>>
>>
>>        # generates first "empty" plots
>>        self.user, self.nice = [], []
>>        self.l_user, = self.ax.plot([], self.user, label='Voltage')
>>        self.l_nice, = self.ax.plot([], self.nice, label='Voltage2')
>>
>>
>>
>>        self.ax.legend()
>>
>>        # force a redraw of the Figure
>>        self.fig.canvas.draw()
>>
>>        self.principal()
>>
>>
>>
>>
>>    def principal(self) :
>>        stop = 0
>>        while stop==0 :
>>            time.sleep(1)
>>            self.set_voltage()
>>            time.sleep(1)
>>            result1 = self.get_info()
>>            result2 = self.get_info2()
>>
>> #          append new data to the datasets
>>            self.user.append(result1)
>>            self.nice.append(result2)
>>
>>        self.l_user.set_data(range(len(self.user)), self.user)
>>        self.l_nice.set_data(range(len(self.nice)), self.nice)
>>
>>        # force a redraw of the Figure
>>
>>        self.fig.canvas.draw()
>>        FigureCanvas.updateGeometry(self)
>>
>>    def get_info(self):
>>        return [0.8]
>>
>>    def get_info2(self) :
>>        return [0.9]
>>
>>    def set_voltage(self) :
>>        print "ok"
>>
>>
>>
>>
>>
>> #===
>> #
>>
>> #===
>>
>>
>>
>> class ApplicationWindow(QtGui.QMainWindow):
>>    """Example main window"""
>>    def __init__(self):
>>        # initialization of Qt MainWindow widget
>>        QtGui.QMainWindow.__init__(self)
>>        # set window title
>>        self.setWindowTitle("QHE manip")
>>        # instantiate a widget, it will be the main one
>>        self.main_widget = QtGui.QWidget(self)
>>        # create a vertical box layout widget
>>        vbl = QtGui.QVBoxLayout(self.main_widget)
>>        # instantiate our Matplotlib canvas widget
>>        qmc = CPUMonitor(self.main_widget)
>>        # instantiate the navigation toolbar
>>        ntb = NavigationToolbar(qmc, self.main_widget)
>>        # pack these widget into the vertical box
>>        vbl.addWidget(qmc)
>>        vbl.addWidget(ntb)
>>
>>        # set the focus on the main widget
>>        self.main_widget.setFocus()
>>        # set the central widget of MainWindow to main_widget
>>        self.setCentralWidget(self.main_widget)
>>
>> # create the GUI application
>> qApp = QtGui.QApplication(sys.argv)
>> # instantiate the ApplicationWindow widget
>> aw = ApplicationWindow()
>> # show the widget
>> aw.show()
>> # start the Qt main loop execution, exiting from this script
>> # with the same return code of Qt application
>> sys.exit(qApp.exec_())
>>
>>
>> --
>> All the data continuously generated in your IT infrastructure
>> contains a definitive record of customers, application performance,
>> security threats, fraudulent activity, and more. Splunk takes this
>> data and makes sense of it. IT sense. And common sense.
>> http://p.sf.net/sfu/splunk-novd2d
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> --
> Daniel Hyams
> dhy...@gmail.com
>
> --

[Matplotlib-users] how to use different font for serif

2011-12-02 Thread Jonathan Slavin
Hi all,

I've been trying to use a different serif font for a plot and have been
running into problems.  I thought I could just do something like:

from matplotlib import rc
rc('font', family='serif', serif='Times New Roman')

but if I try that I end up getting:
findfont: Font family ['serif'] not found. Falling back to Bitstream
Vera Sans

It works fine without the serif='...' part and gives me the default
serif font.  I know that Times New Roman exists on my system -- at least
the GNOME character map can find it.  Perhaps I need to use a different
alias (but what would it be?).  Any help would appreciated.

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
__


--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] how to use different font for serif

2011-12-02 Thread Tony Yu
On Fri, Dec 2, 2011 at 4:13 PM, Jonathan Slavin wrote:

> Hi all,
>
> I've been trying to use a different serif font for a plot and have been
> running into problems.  I thought I could just do something like:
>
> from matplotlib import rc
> rc('font', family='serif', serif='Times New Roman')
>
> but if I try that I end up getting:
> findfont: Font family ['serif'] not found. Falling back to Bitstream
> Vera Sans
>
> It works fine without the serif='...' part and gives me the default
> serif font.  I know that Times New Roman exists on my system -- at least
> the GNOME character map can find it.  Perhaps I need to use a different
> alias (but what would it be?).  Any help would appreciated.
>
> Jon
>


You should check what fonts are installed on your system:

>>> from matplotlib import font_manager
>>> font_manager.OSXInstalledFonts()

(or if you're on a different system, try MSInstalledFonts or
X11InstalledFonts---those aren't available on my system, but presumably
that's just because I'm using OSX). If that works, then look for Times New
Roman in what's printed out. If it is, the problem may be that it's not the
right format: it appears as
ifthe
font_manager only supports .ttf and .afm fonts.

If you don't see Times New Roman in any of those files, check the output of

>>> mpl.font_manager.OSXFontDirectories

(replacing OSX with MS or X11, if needed). If the listed directories
doesn't match your installation of Times New Roman, that's your problem.
(I'm not sure if there's a good way of adding directories.)

Cheers,
-Tony
--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users