SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S
1
(1)
2
(12)
3
(12)
4
(19)
5
(7)
6
(6)
7
(2)
8
(2)
9
(11)
10
(15)
11
(27)
12
(27)
13
(18)
14
(3)
15
(3)
16
(25)
17
(9)
18
(3)
19
(4)
20
(2)
21
(4)
22
(9)
23
(28)
24
(18)
25
(16)
26
(9)
27
(4)
28
(13)
29
(15)
30
(33)





Showing results of 346

<< < 1 2 3 4 .. 14 > >> (Page 2 of 14)
From: Wayne W. <sie...@sb...> - 2009年11月30日 05:42:53
Eric Firing wrote:
> Wayne Watson wrote:
>> I have a fairly large program that uses pylab and company. I want to 
>> use the matplot histogram function. Here are the declarations at the 
>> start. I added import matplotlib as mpl
>> ---------------------start
>> from Tkinter import *
>> from numpy import *
>> import numpy
>> import pylab
>> import Image
>> import ImageChops
>> import ImageTk
>> import time
>> import binascii
>> import tkMessageBox
>> import tkSimpleDialog
>> from pylab import plot, xlabel, ylabel, title, show, xticks, bar
>> import matplotlib as mpl <<<<---------- added
>>
>> from tkFileDialog import asksaveasfilename
>> from tkFileDialog import askopenfilename
>>
>> import MakeQTE
>>
>> import socket
>>
>> ... 500 lines of code
>>
>> I've added the follow code in a function
>> print "pltx_bins: ", pltx_bins
>> print "Off to pylab: ", plt_bins[0:nplt_bins]
>> fig = mpl.figure()
>> v = array(plt_bins)
>> print "v is: ",v
>> print "edges --", linspace(0,256,nplt_bins+1)
>> mpl.histogram(v, bins=linspace(0,256,nplt_bins+1), normed=1)# 
>> matplotlib version (plot)
>> mpl.show()
>> print "end of histogram output"
>> # end of function
>> -------------------------end
>> The program dies at fig = figure() with:
>> Exception in Tkinter callback
>> Traceback (most recent call last):
>> File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
>> return self.func(*args)
>> File 
>> "C:\Sandia_Meteors\Sentinel_Development\Development_Sentuser+Utilities\sentuser\sentuser_20090103+hist.py", 
>> line 504, in ShowHistogram
>> fig = mpl.figure()
>> TypeError: 'module' object is not callable
>>
>> What's the problem here?
>>
>>
>
> figure(), show(), etc. are pylab (or matplotlib.pyplot) functions, not 
> matplotlib functions.
>
> Especially for a long program, it is strongly recommended that you not 
> use "from numpy import *". The recommended form is
>
> import numpy as np
> import matplotlib.pyplot as plt
>
> It will help you keep a clear picture of where various types of 
> functionality are coming from. See also 
> http://matplotlib.sourceforge.net/faq/usage_faq.html
> and note that a primarily object-oriented approach is recommended for 
> use in other than quick scripts and interactive plotting.
>
> Eric
>
Thanks. Well, that explains a lot! functions in the wrong place.
I'm pretty new to this stuff, so what belongs where is sometimes 
unclear. I'll check out the sourceforge tip. I didn't write the program. 
I'm just trying to add some features. Changing the import for matplotlib 
got the graphics window up.
 import matplotlib.pyplot as plt
When I ran it, it was followed by this traceback:
------------start
Exception in Tkinter callback
Traceback (most recent call last):
 File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
 return self.func(*args)
 File 
"C:\Sandia_Meteors\Sentinel_Development\Development_Sentuser+Utilities\sentuser\sentuser_20090103+hist.py", 
line 508, in ShowHistogram
 plt.histogram(v, bins=linspace(0,256,nplt_bins+1), normed=1)# 
matplotlib version (plot)
AttributeError: 'module' object has no attribute 'histogram'
---------------end
508 line is the histogram. Who's complaining? ShowHistogram? I don't 
believe I should be using hist here instead of histogram.
Off to sourceforge.
-- 
 Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
 Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet 
 
 The popular press and many authorities believe the number
 of pedifiles that prowl the web is 50,00. There are no
 figures that support this. The number of children below
 18 years of age kidnapped by strangers is 1 in 600,00,
 or 115 per year. -- The Science of Fear by D. Gardner
 
 Web Page: <www.speckledwithstars.net/>
From: Alan G I. <ala...@gm...> - 2009年11月30日 05:12:14
On 11/29/2009 11:44 PM, Eric Firing wrote:
> in svn there is such an option, but it still doesn't seem to
> do exactly the right thing in this case
OK, looking forward ...
Thanks,
Alan
From: Eric F. <ef...@ha...> - 2009年11月30日 05:01:04
Wayne Watson wrote:
> I have a fairly large program that uses pylab and company. I want to use 
> the matplot histogram function. Here are the declarations at the start. 
> I added import matplotlib as mpl
> ---------------------start
> from Tkinter import *
> from numpy import *
> import numpy
> import pylab
> import Image
> import ImageChops
> import ImageTk
> import time
> import binascii
> import tkMessageBox
> import tkSimpleDialog
> from pylab import plot, xlabel, ylabel, title, show, xticks, bar
> import matplotlib as mpl <<<<---------- added
> 
> from tkFileDialog import asksaveasfilename
> from tkFileDialog import askopenfilename
> 
> import MakeQTE
> 
> import socket
> 
> ... 500 lines of code
> 
> I've added the follow code in a function
> print "pltx_bins: ", pltx_bins
> print "Off to pylab: ", plt_bins[0:nplt_bins]
> fig = mpl.figure()
> v = array(plt_bins)
> print "v is: ",v
> print "edges --", linspace(0,256,nplt_bins+1)
> mpl.histogram(v, bins=linspace(0,256,nplt_bins+1), normed=1)# 
> matplotlib version (plot)
> mpl.show()
> print "end of histogram output"
> # end of function
> -------------------------end
> The program dies at fig = figure() with:
> Exception in Tkinter callback
> Traceback (most recent call last):
> File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
> return self.func(*args)
> File 
> "C:\Sandia_Meteors\Sentinel_Development\Development_Sentuser+Utilities\sentuser\sentuser_20090103+hist.py", 
> line 504, in ShowHistogram
> fig = mpl.figure()
> TypeError: 'module' object is not callable
> 
> What's the problem here?
> 
> 
figure(), show(), etc. are pylab (or matplotlib.pyplot) functions, not 
matplotlib functions.
Especially for a long program, it is strongly recommended that you not 
use "from numpy import *". The recommended form is
import numpy as np
import matplotlib.pyplot as plt
It will help you keep a clear picture of where various types of 
functionality are coming from. See also 
http://matplotlib.sourceforge.net/faq/usage_faq.html
and note that a primarily object-oriented approach is recommended for 
use in other than quick scripts and interactive plotting.
Eric
From: Eric F. <ef...@ha...> - 2009年11月30日 04:45:01
Alan G Isaac wrote:
> On 11/29/2009 12:10 PM, Eric Firing wrote:
>> quiver(x[:-1], y[:-1], u, v, angles='xy', units='x', scale=1)
>>
> 
> That works perfectly when there is change only in x,
> but not when both coordinates change. It seems like
> I want a `units='xy'` option, to get the right
> scaling along each axis, but it does not exist.
Actually, in svn there is such an option, but it still doesn't seem to 
do exactly the right thing in this case. I haven't yet figured out why not.
Eric
> 
> However I can "fake it" pretty well by plotting
> first with lines and then on top of that doing
> quiver(x[1:],y[1:],u,v, pivot='tip', angles='xy')
> 
> Thanks,
> Alan
From: Wayne W. <sie...@sb...> - 2009年11月30日 03:09:18
I have a fairly large program that uses pylab and company. I want to use 
the matplot histogram function. Here are the declarations at the start. 
I added import matplotlib as mpl
---------------------start
from Tkinter import *
from numpy import *
import numpy
import pylab
import Image
import ImageChops
import ImageTk
import time
import binascii
import tkMessageBox
import tkSimpleDialog
from pylab import plot, xlabel, ylabel, title, show, xticks, bar
import matplotlib as mpl <<<<---------- added
from tkFileDialog import asksaveasfilename
from tkFileDialog import askopenfilename
import MakeQTE
import socket
... 500 lines of code
 I've added the follow code in a function
 print "pltx_bins: ", pltx_bins
 print "Off to pylab: ", plt_bins[0:nplt_bins]
 fig = mpl.figure()
 v = array(plt_bins)
 print "v is: ",v
 print "edges --", linspace(0,256,nplt_bins+1)
 mpl.histogram(v, bins=linspace(0,256,nplt_bins+1), normed=1)# 
matplotlib version (plot)
 mpl.show()
 print "end of histogram output"
 # end of function
-------------------------end
The program dies at fig = figure() with:
Exception in Tkinter callback
Traceback (most recent call last):
 File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
 return self.func(*args)
 File 
"C:\Sandia_Meteors\Sentinel_Development\Development_Sentuser+Utilities\sentuser\sentuser_20090103+hist.py", 
line 504, in ShowHistogram
 fig = mpl.figure()
TypeError: 'module' object is not callable
What's the problem here?
-- 
 Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
 Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet 
 
 350 350 350 350 350 350 350 350 350 350
 Make the number famous. See 350.org
 The major event has passed, but keep the number alive.
 
 Web Page: <www.speckledwithstars.net/>
From: Alastair M. <amc...@go...> - 2009年11月30日 00:35:28
Hi JJ,
Thanks very much that was exactly the right solution!
Best regards,
Alastair
On Sat, Nov 28, 2009 at 12:55 AM, Jae-Joon Lee <lee...@gm...> wrote:
> Maybe this thread is helpful.
>
>
> http://old.nabble.com/Problem-with-simple-use-of-draw%28%29-in-animations-of-arrays-tt26174627.html#a26175190
>
> I guess your code will work simply by calling "recache()" instead of
> set_ydata.
>
> Regards,
>
> -JJ
>
>
> On Sat, Nov 28, 2009 at 4:50 AM, Alastair McKinley
> <amc...@go... <amckinley03%2B...@go...>>
> wrote:
> > Hi everyone,
> >
> > I am a new matplotlib user building a simple visualization tool.
> >
> > I was having some issues with the graph not redrawing and I think I have
> > reduced it to a minimal case that doesn't work as expected for me.
> >
> > In the example below one of the data elements is changed on every
> iteration
> > of the update function, but the graph does not update as expected.
> >
> > Am I making a mistake in my usage?
> >
> > Alastair
> >
> >
> >
> > #!/usr/bin/env python
> >
> > import gtk
> > import gobject
> > from matplotlib.figure import Figure
> > import numpy as np
> >
> > from matplotlib.backends.backend_
> > gtkagg import FigureCanvasGTKAgg as FigureCanvas
> >
> > def update(line):
> > global data
> > data[20]=data[20]+0.5
> > line.set_ydata(data)
> > line.axes.figure.canvas.draw()
> > return True
> >
> > win = gtk.Window()
> > win.connect("destroy", lambda x: x.destroy())
> > win.set_default_size(400,300)
> > fig = Figure(figsize=(5,4), dpi=100)
> > ax = fig.add_subplot(111)
> > canvas = FigureCanvas(fig)
> > win.add(canvas)
> >
> > data = np.random.randn(100)
> > line, = ax.plot(data)
> >
> > win.show_all()
> >
> > gobject.timeout_add(1000,update,line)
> >
> > gtk.main()
> >
> >
> ------------------------------------------------------------------------------
> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> > trial. Simplify your report design, integration and deployment - and
> focus
> > on
> > what you do best, core application coding. Discover what's new with
> > Crystal Reports now. http://p.sf.net/sfu/bobj-july
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> >
>
From: Michael C. <mc...@ca...> - 2009年11月29日 21:13:41
The arrows worked quite well, but I can't figure out how to curve them 
in a natural way, so they don't overlap. Also, how do I alter the 
breadth of the arrowhead, and to make it the same size along arrows of 
all lengths?
Cheers,
Mike
Jose Gomez-Dans wrote:
> Hi,
> 2009年11月29日 Michael Cohen <mc...@ca... <mailto:mc...@ca...>>
> 
> Hi all,
> 
> I have a plot that has say 6 black X's, each separate, and 6 blue X's,
> also separate, denoting where x's 1-6 have moved to (from black to
> blue).
> Currently each point is plotted with a separate plot function.
> I would like to generate a plot where each black x and blue x pair has
> an arrow pointing from one to the other.
> 
> 
> See this cookbook entry: <http://www.scipy.org/Cookbook/Matplotlib/Arrows>
> 
> What I usually do in these circumstances (and what is demonstrated in 
> the cookbook entry) is to plot the points, and then add an arrow patch 
> for each pair:
> arrow = pylab.Arrow ( x_from, y_from, distance_x, distance_y )
> ax = pylab.gca()
> ax.add_patch(arrow)
> 
> Hope that helps!
> Jose
From: Johan G. <joh...@gm...> - 2009年11月29日 21:11:43
Wayne Watson skrev:
> So far matplotlib pretty much leaves the user on his own. Yes, there are
> plenty of examples, but there seem to be no explanations about matters
> like figure or show. No tutor on any of this I guess. Apparently, they
> are leaving it up to one's MATLAB experience. It's been quite awhile
> since I used that. It still resides on my computer.
> 
I have mostly used my experience from matlab and other graphics 
packages, along with the examples and documentation available on the 
webpage, but there is now also a book about matplotlib.
http://sandrotosi.blogspot.com/2009/11/matplotlib-for-python-developers.html
/ johan
From: Alan G I. <ai...@am...> - 2009年11月29日 20:29:04
On 11/29/2009 12:10 PM, Eric Firing wrote:
> quiver(x[:-1], y[:-1], u, v, angles='xy', units='x', scale=1)
>
That works perfectly when there is change only in x,
but not when both coordinates change. It seems like
I want a `units='xy'` option, to get the right
scaling along each axis, but it does not exist.
However I can "fake it" pretty well by plotting
first with lines and then on top of that doing
quiver(x[1:],y[1:],u,v, pivot='tip', angles='xy')
Thanks,
Alan
From: Wayne W. <sie...@sb...> - 2009年11月29日 18:30:01
I'm on Win XP, and have no idea where the images went. I guess I'll have
to search my C-disk. I just began the search.
Looking at C:\Python25, I see no image files. Same with C:\Python25\Scripts
If I put some code up front as below, the image comes up on my screen,
but using a range of 0 to 8 and 0, 18 changes nothing. Further the
program hangs up.
So far matplotlib pretty much leaves the user on his own. Yes, there are
plenty of examples, but there seem to be no explanations about matters
like figure or show. No tutor on any of this I guess. Apparently, they
are leaving it up to one's MATLAB experience. It's been quite awhile
since I used that. It still resides on my computer.
Ah, the png files were found in the folder where the program is located.
I can clearly see the changes from your switches between range values.
=================inserted a few lines at the top and some print debug
stmts=====
import matplotlib.pyplot as plt
print "let's start the histogram"
plt.hist([1, 2, 3, 4, 5], range=(0, 18))
plt.show()
#raw_input("Hey")
fig = plt.figure()
plt.hist([1, 2, 3, 4, 5], range=(0, 20))
plt.show()
plt.savefig("hist_0_20.png")
plt.close(fig)
fig = plt.figure()
plt.hist([1, 2, 3, 4, 5], range=(0, 8))
plt.savefig("hist_0_8.png")
plt.close(fig)
print "finished"
Johan Grönqvist wrote:
> Wayne Watson skrev:
> 
>> Anyway, where, folder, does your program write the files? I'm not
>> familiar with figure, but apparently using it produces some "canvas"
>> that plt.hist places it's output on. One can than save fig to a file.
>> What happens if I don't use figure? I just put a copy of the line
>> plt.hist([1, 2, 3, 4, 5], range=(0, 20)) after import. When I execute
>> the program, I don't see a graphic appear. So doesn't matplotlib produce
>> graphic output aside from use of figure?
>>
>> 
>
> My intuition is exactly like that.
>
> After importing matplotlib.pyplt as plt, plt.figure creates an object 
> that acts as canvas, and then I plot various things (hist, is one 
> example), and when I am satisfied, I plt.savefig(path) or plt.show() the 
> figure. The figures are saved in the directory where the script is run 
> (its cwd, or current working directory, on linux).
>
> I have also used hist without having a figure, but that was because I 
> wanted the histogram data, i.e., the numbers of data points in the 
> different bins. That script used plt.hist to generate such data, and 
> later (after running fig = plt.figure) used plt.plot to plot parts of 
> the data in different ways.
>
> By the way, matplotlib.pyplot is one way of using matplotlib. There is 
> also the "object oriented interface", which I have never used.
>
>
>
>
>
> / johan
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
> 
-- 
 Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
 Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
 350 350 350 350 350 350 350 350 350 350
 Make the number famous. See 350.org
 The major event has passed, but keep the number alive.
 Web Page: <www.speckledwithstars.net/>
From: Mike A. <mba...@wi...> - 2009年11月29日 18:13:02
Hi!
>> How can I put the bottom axis on top (or on top AND on bottom) for a barh plot?
> It's somewhat counter-intuitive, but it can be done.
> You have to create some "twin" axes with the "twiny" option,
> then make the plot on the twin axes so it will use the
> top axis. The bottom axis still have to be adjusted manually
> to make it match the top one and remove the labels.
> 
> See this example:
> 
Thanks for your example. With your help I was able to finally create this with matplotlib,
 http://www.hep.wisc.edu/cms/comp/cmsprod/diskUserUsage.png
and this is my final script,
 http://www.hep.wisc.edu/cms/comp/cmsprod/plotDiskUse.py
One thing that surprised me was to shrink the font for the names required changing ax1 even though the barh plot is on ax2. See these lines:
----------
 ax2.barh(pos, listUse, color=listColors, height=1.0, align='center')
 ...
 for tick in ax1.yaxis.get_major_ticks():
 tick.label1.set_fontsize(8)
----------
Surprising.
Mike
From: Johan G. <joh...@gm...> - 2009年11月29日 17:24:43
Wayne Watson skrev:
> Anyway, where, folder, does your program write the files? I'm not
> familiar with figure, but apparently using it produces some "canvas"
> that plt.hist places it's output on. One can than save fig to a file.
> What happens if I don't use figure? I just put a copy of the line
> plt.hist([1, 2, 3, 4, 5], range=(0, 20)) after import. When I execute
> the program, I don't see a graphic appear. So doesn't matplotlib produce
> graphic output aside from use of figure?
> 
My intuition is exactly like that.
After importing matplotlib.pyplt as plt, plt.figure creates an object 
that acts as canvas, and then I plot various things (hist, is one 
example), and when I am satisfied, I plt.savefig(path) or plt.show() the 
figure. The figures are saved in the directory where the script is run 
(its cwd, or current working directory, on linux).
I have also used hist without having a figure, but that was because I 
wanted the histogram data, i.e., the numbers of data points in the 
different bins. That script used plt.hist to generate such data, and 
later (after running fig = plt.figure) used plt.plot to plot parts of 
the data in different ways.
By the way, matplotlib.pyplot is one way of using matplotlib. There is 
also the "object oriented interface", which I have never used.
/ johan
From: Eric F. <ef...@ha...> - 2009年11月29日 17:10:26
Alan G Isaac wrote:
> I have a collection of 2d points xy.
> Instead of simply plotting the points,
> I'd like to plot a collection of arrows
> that goes from each point to the next.
> The "from" is easy of course;
> the "to" is the problem.
> 
> I think I should be able to use quiver,
> but I'm not getting it quite right.
> E.g.,
> 
> x,y = zip(*xy)
> u,v = np.diff(x), np.diff(y)
> quiver(x[:-1], y[:-1], u, v, angles='xy')
> 
> looks like a start but does not get there.
> I guessed that `scale=1` would complete
> the picture, but that just showed that I
> misunderstood `scale`.
> 
> Suggestions?
Try this:
quiver(x[:-1], y[:-1], u, v, angles='xy', units='x', scale=1)
Eric
From: Wayne W. <sie...@sb...> - 2009年11月29日 15:56:50
Hi, this is an odd result. I copied your code and tried to execute it
with Python 2.5. It came back with a socket area, and a reference to my
firewall. Very strange. Ah, I happen to have a comm port open to another
computer. Apparently Python didn't like that.
Anyway, where, folder, does your program write the files? I'm not
familiar with figure, but apparently using it produces some "canvas"
that plt.hist places it's output on. One can than save fig to a file.
What happens if I don't use figure? I just put a copy of the line
plt.hist([1, 2, 3, 4, 5], range=(0, 20)) after import. When I execute
the program, I don't see a graphic appear. So doesn't matplotlib produce
graphic output aside from use of figure?
I think I've confused hist as part of numpy and histogram as part of
matplotlib. A visit to the numpy and matplotlib web sites shows I am
confused.
Let's see. I want to know how to use a histogram in Python, so there is
a histogram function and a hist. So a histogram is for histograms. What
fun word play. :-) Maybe numpy should have called their function ahistogram!
Johan Grönqvist wrote:
> Wayne Watson skrev:
> 
>> See Subject. I don't seem able to produce a simple example of using 
>> histogram that uses range. I tried a variety of ranges, range=(0,22), 
>> range=(0, 50.2), ... and I see no difference between any of the x values 
>> scale. Can someone provide an example that shows how it works?
>>
>> 
>
> The script below works for me. It produces two files with different 
> limits on the x-axis and corresponding histograms.
>
>
> ------------
> import matplotlib.pyplot as plt
>
> fig = plt.figure()
> plt.hist([1, 2, 3, 4, 5], range=(0, 20))
> plt.savefig("hist_0_20.png")
> plt.close(fig)
>
> fig = plt.figure()
> plt.hist([1, 2, 3, 4, 5], range=(0, 8))
> plt.savefig("hist_0_8.png")
> plt.close(fig)
> -------------
>
> Hope it helps
>
> / johan
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
> 
-- 
 Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
 Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
 350 350 350 350 350 350 350 350 350 350
 Make the number famous. See 350.org
 The major event has passed, but keep the number alive.
 Web Page: <www.speckledwithstars.net/>
From: Alan G I. <ai...@am...> - 2009年11月29日 15:11:02
I have a collection of 2d points xy.
Instead of simply plotting the points,
I'd like to plot a collection of arrows
that goes from each point to the next.
The "from" is easy of course;
the "to" is the problem.
I think I should be able to use quiver,
but I'm not getting it quite right.
E.g.,
x,y = zip(*xy)
u,v = np.diff(x), np.diff(y)
quiver(x[:-1], y[:-1], u, v, angles='xy')
looks like a start but does not get there.
I guessed that `scale=1` would complete
the picture, but that just showed that I
misunderstood `scale`.
Suggestions?
Alan Isaac
From: Jose Gomez-D. <jgo...@gm...> - 2009年11月29日 11:49:43
Hi,
2009年11月29日 Michael Cohen <mc...@ca...>
> Hi all,
>
> I have a plot that has say 6 black X's, each separate, and 6 blue X's,
> also separate, denoting where x's 1-6 have moved to (from black to blue).
> Currently each point is plotted with a separate plot function.
> I would like to generate a plot where each black x and blue x pair has
> an arrow pointing from one to the other.
>
See this cookbook entry: <http://www.scipy.org/Cookbook/Matplotlib/Arrows>
What I usually do in these circumstances (and what is demonstrated in the
cookbook entry) is to plot the points, and then add an arrow patch for each
pair:
arrow = pylab.Arrow ( x_from, y_from, distance_x, distance_y )
ax = pylab.gca()
ax.add_patch(arrow)
Hope that helps!
Jose
From: Jorge S. <jor...@ya...> - 2009年11月29日 11:10:48
Hi,
I have a strong preference to working with the keyboard instead of the mouse.
Today I was working on a script to label a sequence of images (mark position and
scale of a moving object). The default keyboard shortcuts are getting in my way,
many keys are already used and moreover they are spread all over the keyboard.
Looking at the doc, I could't find an easy way to customize or completely
disable them. If someone can suggest a (not too coonvoluted) solution, I'd love
to hear it.
Cheers,
Jorge
From: Johan G. <joh...@gm...> - 2009年11月29日 09:09:28
Wayne Watson skrev:
> See Subject. I don't seem able to produce a simple example of using 
> histogram that uses range. I tried a variety of ranges, range=(0,22), 
> range=(0, 50.2), ... and I see no difference between any of the x values 
> scale. Can someone provide an example that shows how it works?
> 
The script below works for me. It produces two files with different 
limits on the x-axis and corresponding histograms.
------------
import matplotlib.pyplot as plt
fig = plt.figure()
plt.hist([1, 2, 3, 4, 5], range=(0, 20))
plt.savefig("hist_0_20.png")
plt.close(fig)
fig = plt.figure()
plt.hist([1, 2, 3, 4, 5], range=(0, 8))
plt.savefig("hist_0_8.png")
plt.close(fig)
-------------
Hope it helps
/ johan
From: Gary R. <gr...@bi...> - 2009年11月29日 09:05:57
Hi Michael,
Take a look at the quiver demo
<http://matplotlib.sourceforge.net/examples/pylab_examples/quiver_demo.html>
and the annotation2 demo
<http://matplotlib.sourceforge.net/examples/pylab_examples/quiver_demo.html>
More generally, have a look through the examples and gallery pages
<http://matplotlib.sf.net/examples/index.html>
<http://matplotlib.sf.net/gallery.html>
Gary R.
Michael Cohen wrote:
> Hi all,
> 
> I have a plot that has say 6 black X's, each separate, and 6 blue X's, 
> also separate, denoting where x's 1-6 have moved to (from black to blue).
> Currently each point is plotted with a separate plot function.
> I would like to generate a plot where each black x and blue x pair has 
> an arrow pointing from one to the other.
> 
> Currently I plot them like this:
> 
> x1black = value
> y1black = value
> plot([x1black],[y1black],'kx',markersize=10,markeredgewidth=2)
> x1blue = value
> y1blue = value
> plot([x1blue],[y1blue],'bx',markersize=10,markeredgewidth=2)
> 
> If I plotted,
> plot([x1black,x1blue],[y1black,y1blue])
> I could make the line between them into an arrow, but I wouldn't be able 
> to make one blue and the other black.
> 
> Also, I'd like to be able to curve my arrows to make them less confusing 
> in case they intersect too much.
> 
> 
> Can anyone point me to the right functions?
> 
> Cheers
> Michael
From: Michael C. <mc...@ca...> - 2009年11月29日 04:14:32
Hi all,
I have a plot that has say 6 black X's, each separate, and 6 blue X's, 
also separate, denoting where x's 1-6 have moved to (from black to blue).
Currently each point is plotted with a separate plot function.
I would like to generate a plot where each black x and blue x pair has 
an arrow pointing from one to the other.
Currently I plot them like this:
x1black = value
y1black = value
plot([x1black],[y1black],'kx',markersize=10,markeredgewidth=2)
x1blue = value
y1blue = value
plot([x1blue],[y1blue],'bx',markersize=10,markeredgewidth=2)
If I plotted,
plot([x1black,x1blue],[y1black,y1blue])
I could make the line between them into an arrow, but I wouldn't be able 
to make one blue and the other black.
Also, I'd like to be able to curve my arrows to make them less confusing 
in case they intersect too much.
Can anyone point me to the right functions?
Cheers
Michael
From: Peter W. <pd...@gm...> - 2009年11月29日 03:18:05
Hi All, 
I'm trying to create a set of strip charts so that I can see the relationships between a large number of time series. I'd like to label the y-axis with a name on the left side and a value/percentile on the right hand side. I can get the names on the left axis, and it looks very nice (yay Matplotlib!). When I try to the code below I don't get the output I'd like. None of the explicit tick labels that I'm setting make it to the display, and also the 3 charts on the page aren't kept separate (left tick labels from chart 132 hit the right tick labels from chart 131). Any suggestions very appreciated. 
import numpy as np
import matplotlib.pyplot as plt
nameN = 25
obsN = 50
names = ["foo%d" % x for x in range(nameN)]
vols = np.random.uniform(0.2, 0.45, nameN)
labels = ['ValA', 'ValB', 'ValC']
d1 = np.random.normal(0,1, obsN*nameN).reshape(obsN, -1)*vols
d2 = np.random.normal(0,1, obsN*nameN).reshape(obsN, -1)*vols
d3 = np.random.normal(0,1, obsN*nameN).reshape(obsN, -1)*vols
f = 0.45
fig = plt.figure()
for label, dset, ax_id in zip(labels, (d1, d2, d3), (131, 132, 133)):
 
 ax = fig.add_subplot(ax_id)
 for i in range(len(names)):
 
 mx = np.max(dset[:,i])
 mn = np.min(dset[:,i])
 y = i + dset[:,i]*2*f/(mx - mn) - f*(mx + mn)/(mx - mn) + 1
 y_last = y[-1]*np.ones_like(y)
 x = np.arange(obsN)
 ax.fill_between(x, y_last, y)
 ax.set_ylim((0, nameN + 1))
 ax.set_yticks(range(1, nameN + 1))
 ax.set_title(label, fontsize=10)
 for tk, nm in zip(ax.yaxis.get_major_ticks(), list(reversed(names))):
 tk.tick1On = False
 tk.tick2On = False
 tk.label1On = True
 tk.label2On = True
 tk.set_label1(nm)
 tk.set_label2("%.1f\n(%.1f tile)" % (36.2, 98.6))
 
 #ytickNames = ax.set_yticklabels(list(reversed(names)), rotation = 45, fontsize = 8)
 
 
plt.show()
From: Wayne W. <sie...@sb...> - 2009年11月28日 19:56:25
See Subject. I don't seem able to produce a simple example of using 
histogram that uses range. I tried a variety of ranges, range=(0,22), 
range=(0, 50.2), ... and I see no difference between any of the x values 
scale. Can someone provide an example that shows how it works?
-- 
 Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
 Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet 
 
 350 350 350 350 350 350 350 350 350 350
 Make the number famous. See 350.org
 The major event has passed, but keep the number alive.
 
 Web Page: <www.speckledwithstars.net/>
From: Jorge S. <jor...@ya...> - 2009年11月28日 19:45:21
Hi,
I was trying to find out when a button_press_event happened inside a patch
(tried Circle and Rectangle) using the contains(mouseevent) method, but it
always seem to return True. I got the inspiration from the looking_glass.py
example, which also doesn't work as (Ithink) it should. I know Ican do this the
hard way, i.e. checking with event.xdata event.ydata, but I was really happy
there was already a pre-defined method for doing so.
Cheers,
Jorge
From: Pau <vim...@go...> - 2009年11月28日 18:05:15
Hello,
I am doing a plot and the x axis shows a small 1e7 indicating that the
numbers should be multiplied by that quantity, but the y axis does not
and is showing labels like 0.000007
Why is that? I would like it to also use the 1eX notation
Any comment will be appreciated
Thanks,
Pau
This is my script
#!/usr/bin/env python
from pylab import *
# Create arrays
H01 = load ('./h01_skipi.txt')
H99 = load ('./h99_skipi.txt')
# Define elements
t_01 = H01[:, 0] # 1st column
hplus_01 = H01[:, 1] # 2nd
hcross_01 = H01[:, 2] # 3rd
t_99 = H99[:, 0] # 1st column
hplus_99 = H99[:, 1] # 2nd
hcross_99 = H99[:, 2] # 3rd
# Create upper plot
subplot (211) # 2 rows 1 column 1st plot
grid(True)
# For settings see page 22 users_guide
ylabel (r'$h_+,円(r/M)$', size=18)
plot(t_01, hplus_01 , \
 linestyle='--', color='grey',
 linewidth=3)
plot(t_99, hplus_99 , \
 linestyle='-',color='red',
 linewidth=1)
# Create lower plot
subplot (212)
grid(True)
ylabel (r'$h_x,円(r/M)$', size=18)
plot(t_01, hcross_01 , \
 linestyle='--', color='grey',
 linewidth=3)
plot(t_99, hcross_99 , \
 linestyle='-', color='red',
 linewidth=1)
xlabel ('t (sec)', size=18) # At the end, so that it's common to all
# Draw the thing
show()
From: Eric F. <ef...@ha...> - 2009年11月28日 18:03:00
Brian Larsen wrote:
> Hello all, 
> 
> several of my colleagues and I are 99% sure we are making the change from IDL to python-matplotlib. I have just one issue that I am trying to work out that I need to solve. We are so far really impressed and looking forward to the change.
> 
> I have seen discussion on this list about imagesc and imshow but none of them have quite answered the questions. In IDL we spent way too much time writing an clone that is still not full featured:
> http://people.bu.edu/balarsen/IDLdoc/imagesc.html
> 
> I have data of probability distributions which have an X and Y array associated with the axes of the 2-d distribution (image). What I don't see how to do in any easy fashion is plot this data in a imshow() manner with the axes correct (which are unevenly distributed and need to be plotted on a log axes). 
> 
> This can be done with contourf(X,Y,Z) but this has a few issues:
> - I dont see how to do a log axes on a contour
> - contour is the wrong plot as the inherent smoothing that a contour does is highly undesirable.
> 
> Using matlab imagesc one can easily make plots similar to:
> http://img269.yfrog.com/i/2dprob.png/
> Imagine taking the above plot and make the "pixels" different sizes so that each "pixel" has identical counting statistics. Now assume that one wanted the Y-axis to be plotted in log.
> 
> Anyone have any thoughts or toy examples?
I am not sure I understand exactly what you want to do, but it sounds 
like pcolormesh would do it. e.g. with ipython -pylab:
ax = gca()
ax.set_yscale('log')
x = np.arange(10)**1.5
y = np.arange(20)**1.8
z = x[1:] * y[1:, np.newaxis]
pcolormesh(x, y, z)
axis('tight')
Note that with x and y, which can be 1-D or 2-D, you are specifying the 
grid boundaries, not the pixel centers.
Eric
11 messages has been excluded from this view by a project administrator.

Showing results of 346

<< < 1 2 3 4 .. 14 > >> (Page 2 of 14)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /