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
(14)
2
(11)
3
(5)
4
(17)
5
(11)
6
(37)
7
(35)
8
(9)
9
(1)
10
(9)
11
(7)
12
(22)
13
(34)
14
(24)
15
(27)
16
(13)
17
(19)
18
(43)
19
(36)
20
(12)
21
(9)
22
(21)
23
(3)
24
(5)
25
(30)
26
(14)
27
(23)
28
(19)
29
(19)
30
(10)
31
(6)






Showing 11 results of 11

From: Markus F. <fel...@gm...> - 2009年05月20日 23:45:21
Hi All,
i am programming an application which extracts binary values from 6
files and plots this values in a bar() element and another one.
The bar Elements are partial one upon the other. I think this results of
my my small x values.
y1 = [1 0]
y2 = [1 0]
y3 = [1 1]
x = [ 0. 0.0002149]
As you can see the x values are near the same.
here is a screenshot,
[url=http://img257.imageshack.us/my.php?image=problemmitkonverter.jpg][img=http://img257.imageshack.us/img257/3134/problemmitkonverter.th.jpg][/url]
My Code is at,
http://nopaste.debianforum.de/21481
here is a short code snippet:
##########################################################################
class GraphWindow(wx.Window):
 def __init__(self, *args, **kwargs):
 wx.Window.__init__(self, *args, **kwargs)
 self.lines = []
 self.figure = Figure()
 self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
 f_dat = open('../../../peakswerteundzeit.dat','rb')
 nitems = 2
 self.a_time = cPickle.load(f_dat)
 self.a_a = cPickle.load(f_dat)
 self.a_b = cPickle.load(f_dat)
 self.a_c = cPickle.load(f_dat)
 self.a_ar = cPickle.load(f_dat)
 self.a_ai = cPickle.load(f_dat)
 self.a_br = cPickle.load(f_dat)
 self.a_bi = cPickle.load(f_dat)
 self.a_cr = cPickle.load(f_dat)
 self.a_ci = cPickle.load(f_dat)
 self.draw(nitems)
 def draw(self,nitems):
 if not hasattr(self, 'subplot1'):
 self.subplot1 = self.figure.add_subplot(211)
 self.subplot2 = self.figure.add_subplot(212)
 a = numpy.array(self.a_a[0:nitems])
 b = numpy.array(self.a_b[0:nitems])
 c = numpy.array(self.a_c[0:nitems])
 d = numpy.array(self.a_time[0:nitems])
 print a, b, c, d, numpy.add(a,b)
 bar1 = self.subplot1.bar(d,a, color='red', 
edgecolor='red',align='edge')
 bar2 = self.subplot1.bar(d,b, color='green', 
edgecolor='green',align='edge',
 bottom=a)
 bar3 = self.subplot1.bar(d,c, color='blue', 
edgecolor='blue',align='edge',
 bottom=numpy.add(a,b))
##########################################################################
Any Ideas how to avoid the one upon the other effect ?
I failed to get the xaxis towork.
Regards Markus
From: Christopher B. <Chr...@no...> - 2009年05月20日 23:14:38
Jeremy Lewi wrote:
> I would like to use matplotlib to incorporate plots into my fltk
> application.
 > The key point is that I
> want to display the figure in a non-blocking way so that control can
> return to my fltk application while the figure is still being displayed.
> To prototype this I have created a file containing the following python
> code
> 
> import sys
> import fltk
> import matplotlib
> matplotlib.use('FltkAgg')
cool! I didn't know there was an Fltk back-end.
> import pylab as p
> import time
> 	
> hf=p.figure()
but anyway, this is your issue. With all the GUI back-ends, if you wan 
to embed the figure in your own app, rather than have pylab create an 
app for you, you need to create the figure a different way, without 
pylab. See the various embedded_in _*** examples:
http://matplotlib.sourceforge.net/examples/user_interfaces/index.html
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: Jeremy L. <jl...@in...> - 2009年05月20日 22:07:27
I would like to use matplotlib to incorporate plots into my fltk
application. I would like to do this by writing a python function to
create the appropriate graphic using matplotlib. When I want to update
the figure, I want to call an update function written by me in python
which computes the new graphic and displays it. The key point is that I
want to display the figure in a non-blocking way so that control can
return to my fltk application while the figure is still being displayed.
To prototype this I have created a file containing the following python
code
import sys
import fltk
import matplotlib
matplotlib.use('FltkAgg')
import pylab as p
import time
	
hf=p.figure()
ha=hf.add_subplot(1,1,1)
ha.plot([1,2,3])
p.draw()
time.sleep(5)
The problem I'm having is that if I execute these commands from a python
shell using:
execfile(filename)
(where filename is a file containing the above commands) then the figure
isn't being drawn until after sleep is executed. What I'd like is for
this function to just make the figure and leave it there while control
returns to the calling function. I can then create the plot from my
application(written in c) by linking with python and calling 'execfile'
where execfile contains the commands to make the plot.
I'm new to Python and appreciate any help.
Thanks.
Jeremy
From: Alan G I. <ala...@gm...> - 2009年05月20日 19:39:11
On 5/18/2009 6:25 PM Yannick Copin apparently wrote:
> rowspan=2, colspan=3) should actually do. What would be the syntax for 
> the following layouts?
>
> +-----+-----+
> | | ax2 |
> | ax1 +-----+
> | | ax3 |
> +-----+-----+
subplot2grid(shape=(2,2), loc=(0,0), rowspan=2)
subplot2grid(shape=(2,2), loc=(0,1))
subplot2grid(shape=(2,2), loc=(1,1))
> +-------+---+
> | | |
> | ax1 |ax3|
> | | |
> +-------+---+
> | ax2 |
> +-----------+
subplot2grid(shape=(3,3), loc=(0,0), rowspan=2, colspan=2)
subplot2grid(shape=(3,3), loc=(0,2), rowspan=2)
subplot2grid(shape=(3,3), loc=(2,0), colspan=3)
Again, consider the tkinter grid manager.
hth,
Alan Isaac
From: Markus H. <mar...@st...> - 2009年05月20日 19:01:02
Am Mittwoch, den 20.05.2009, 10:21 -0500 schrieb Ryan May:
> 
> Except that it won't work like that. :) (I actually tried that the
> first time) You need to give Figure.colorbar() the mappable as the
> first argument. So this would then become:
> 
> ax1 = fig.add_subplot(231,aspect='equal')
> pc = ax1.pcolor(xsr)
> ax1.axis([0, 127, 0, 127])
> fig.colorbar(pc)
Yep, that's it. It works now. Thank you for your help,
Cheers,
Markus
From: Markus H. <mar...@st...> - 2009年05月20日 15:22:58
Thank you very much for your detailed explanations. When I try
plot1 = fig.add_subplot(231,aspect='equal')
plot1.pcolor(xsr)
plot1.axis([0, 127, 0, 127])
plt.colorbar()
I get the error message
AttributeError: 'NoneType' object has no attribute 'autoscale_None'
WARNING: Failure executing file: <test.py>
But I don't really know, what this means.
> It may be a good idea and refer to the return value of fig.add_subplot
> as "ax" or something that, rather than "plot1" because add_subplot
> returns an Axes instance and thus ax is a better mnemonic; see
> 
Thank you very much, I was not aware of that. However, if I try
fig = plt.figure()
ax1 = fig.add_subplot(231,aspect='equal')
ax1.pcolor(xsr)
ax1.axis([0, 127, 0, 127])
fig.colorbar()
I also get an error message:
TypeError: colorbar() takes at least 2 arguments (1 given)
WARNING: Failure executing file: <test.py>
Cheers,
Markus
From: Ryan M. <rm...@gm...> - 2009年05月20日 15:22:15
On Wed, May 20, 2009 at 10:04 AM, John Hunter <jd...@gm...> wrote:
> On Wed, May 20, 2009 at 9:53 AM, Ryan May <rm...@gm...> wrote:
>
> > Thanks for the full example, but if you carefully read the exception, it
> was
> > telling you the problem. :) plot1 here is an axes object, which does not
> > have a colorbar() method. Instead, you should change that to:
> >
> > plt.colorbar()
> >
> > Assuming everything else was working, you should be good to go with this
> > change.
> >
>
> It looks like Markus is trying to use the API, so rather than suggest
> the pyplot colorbar method, I suggest using the figure instance
> method. Markus the pyplot method plt.colorbar is a thin wrapper
> around the figure method fig.colorbar -- see also:
>
>
> http://matplotlib.sourceforge.net/faq/usage_faq.html#matplotlib-pylab-and-pyplot-how-are-they-related
>
>
> http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.colorbar
>
> It may be a good idea and refer to the return value of fig.add_subplot
> as "ax" or something that, rather than "plot1" because add_subplot
> returns an Axes instance and thus ax is a better mnemonic; see
>
>
> http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.add_subplot
>
> So I suggest something like::
>
> fig = plt.figure()
>
> ax1 = fig.add_subplot(231,aspect='equal')
> ax1.pcolor(xsr)
> ax1.axis([0, 127, 0, 127])
> fig.colorbar()
Except that it won't work like that. :) (I actually tried that the first
time) You need to give Figure.colorbar() the mappable as the first
argument. So this would then become:
 ax1 = fig.add_subplot(231,aspect='equal')
 pc = ax1.pcolor(xsr)
 ax1.axis([0, 127, 0, 127])
 fig.colorbar(pc)
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from Norman, Oklahoma, United States
From: John H. <jd...@gm...> - 2009年05月20日 15:04:46
On Wed, May 20, 2009 at 9:53 AM, Ryan May <rm...@gm...> wrote:
> Thanks for the full example, but if you carefully read the exception, it was
> telling you the problem. :) plot1 here is an axes object, which does not
> have a colorbar() method. Instead, you should change that to:
>
> plt.colorbar()
>
> Assuming everything else was working, you should be good to go with this
> change.
>
It looks like Markus is trying to use the API, so rather than suggest
the pyplot colorbar method, I suggest using the figure instance
method. Markus the pyplot method plt.colorbar is a thin wrapper
around the figure method fig.colorbar -- see also:
 http://matplotlib.sourceforge.net/faq/usage_faq.html#matplotlib-pylab-and-pyplot-how-are-they-related
 http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.colorbar
It may be a good idea and refer to the return value of fig.add_subplot
as "ax" or something that, rather than "plot1" because add_subplot
returns an Axes instance and thus ax is a better mnemonic; see
 http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.add_subplot
So I suggest something like::
 fig = plt.figure()
 ax1 = fig.add_subplot(231,aspect='equal')
 ax1.pcolor(xsr)
 ax1.axis([0, 127, 0, 127])
 fig.colorbar()
JDH
From: Ryan M. <rm...@gm...> - 2009年05月20日 14:53:38
On Wed, May 20, 2009 at 3:17 AM, marcusantonius <
mar...@st...> wrote:
>
> Hi everybody,
> I have the problem, that I cannot add a color bar to a pcolor plot, which I
> generate of some Data files. If I do
> fig = plt.figure()
>
> plot1 = fig.add_subplot(231,aspect='equal')
> plot1.pcolor(xsr)
> plot1.axis([0, 127, 0, 127])
> plot1.colorbar()
>
> it just gives me
> AttributeError: 'AxesSubplot' object has no attribute 'colorbar'
> WARNING: Failure executing file: <test.py>
>
> What am I doing wrong? At the end of this file you find the whole plot-file
Thanks for the full example, but if you carefully read the exception, it was
telling you the problem. :) plot1 here is an axes object, which does not
have a colorbar() method. Instead, you should change that to:
plt.colorbar()
Assuming everything else was working, you should be good to go with this
change.
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from Norman, Oklahoma, United States
From: marcusantonius <mar...@st...> - 2009年05月20日 08:17:30
Hi everybody, 
I have the problem, that I cannot add a color bar to a pcolor plot, which I
generate of some Data files. If I do
fig = plt.figure()
plot1 = fig.add_subplot(231,aspect='equal')
plot1.pcolor(xsr)
plot1.axis([0, 127, 0, 127])
plot1.colorbar()
it just gives me
AttributeError: 'AxesSubplot' object has no attribute 'colorbar'
WARNING: Failure executing file: <test.py>
What am I doing wrong? At the end of this file you find the whole plot-file
Thank you for your help,
Markus
#!usr/bin/python
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
# Open files
file1 = open('../physical/x-ray/193XM_phys.am', 'rb')
file1.seek(-131072,2) 
xm=np.fromfile(file1,dtype='>d')
file1.close()
file2 = open('../physical/x-ray/193XSB_phys.am', 'rb')
file2.seek(-131072,2)
xs=np.fromfile(file2,dtype='>d')
file2.close()
file3 = open('../physical/x-ray/193XT_phys.am', 'rb')
file3.seek(-131072,2)
xt=np.fromfile(file3,dtype='>d')
file3.close()
xsr=np.transpose(np.reshape(xs,(128,128)))
xtr=np.transpose(np.reshape(xt,(128,128)))
xmr=np.transpose(np.reshape(xm,(128,128)))
ind_xmax=np.where(xsr==np.max(xsr))[1][0]
ind_ymax=np.where(xsr==np.max(xsr))[0][0]
profil_xsr=np.zeros(np.minimum(ind_xmax,ind_ymax))
profil_xtr=np.zeros(np.minimum(ind_xmax,ind_ymax))
profil_xmr=np.zeros(np.minimum(ind_xmax,ind_ymax))
anzahl_gridpunkte=np.zeros(np.minimum(ind_xmax,ind_ymax))
for k in range(0,26):
 # Schleife über alle Gitterzellen
 for i in range(128):
	for j in range (128):
	 if (k)**2 < (i-ind_ymax)**2+(j-ind_xmax)**2 <= (k+1)**2:
		profil_xsr[k]=profil_xsr[k]+xsr[i][j]
		profil_xtr[k]=profil_xtr[k]+xtr[i][j]
		profil_xmr[k]=profil_xmr[k]+xmr[i][j]
		anzahl_gridpunkte[k]=anzahl_gridpunkte[k]+1
profil_xsr=profil_xsr/anzahl_gridpunkte
profil_xtr=profil_xtr/anzahl_gridpunkte
profil_xmr=profil_xmr/anzahl_gridpunkte
 
fig = plt.figure()
plot1 = fig.add_subplot(231,aspect='equal')
plot1.pcolor(xsr)
plot1.axis([0, 127, 0, 127])
plot1.colorbar()
plot2 = fig.add_subplot(232,aspect='equal')
plot2.pcolor(10**xtr)
plot2.axis([1, 128, 1, 128])
plot3 = fig.add_subplot(233,aspect='equal')
plot3.pcolor(xmr,vmin=0.0,vmax=0.5)
plot3.axis([1, 128, 1, 128])
plot4 = fig.add_subplot(234)
plot4.plot(profil_xsr)
plot4.axis(ymin=0, ymax=10)
plot5 = fig.add_subplot(235)
plot5.plot(profil_xtr)
plot5.axis(ymin=0, ymax=10)
plot6 = fig.add_subplot(236)
plot6.plot(profil_xmr)
plot6.axis([0, 25,0, 1])
fig.show()
-- 
View this message in context: http://www.nabble.com/Colorbar-for-pcolor-plot-tp23631013p23631013.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: guillaume r. <gra...@wy...> - 2009年05月20日 07:15:00
Christopher Barker wrote:
> John Hunter wrote:
>> You cannot import pylab or pyplot is you are embedding mpl in wx
>> (totally unsupported and expected to fail) -- you need to follow the
>> patterns in
>>
>> http://matplotlib.sourceforge.net/examples/user_interfaces/index.html
> 
> or use wxMPL:
> 
> http://agni.phys.iit.edu/~kmcivor/wxmpl/
> 
> 
> -Chris
> 
> 
I feel like I could have found out by myself xD
thanks !
----
This message contains confidential information and may contain information that is legally privileged. If you have received this message by mistake, please immediately notify us and delete the original message. Thank you. 
Ce message contient des informations confidentielles. S'il vous est parvenu par erreur, merci de bien vouloir nous en aviser par retour, de n'en faire aucun usage et de n'en garder aucune copie.
----
1 message has been excluded from this view by a project administrator.

Showing 11 results of 11

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 によって変換されたページ (->オリジナル) /