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





Showing 10 results of 10

From: Michael C. <mc...@ca...> - 2009年08月21日 23:54:03
Hi all,
At the Scipy2009 conference I was recently told I could get better 
performance from matplotlib through an ssh tunnel by using a different 
backend. However, I can't find any introductory material on this, just 
function docs for backend_bases module. What part of the matplotlib 
call includes backend specification? What backends work well for ssh 
tunnels?
Cheers,
Mike
From: Chloe L. <ch...@na...> - 2009年08月21日 18:40:27
The sixteen lines of data you sent work in a little histogram- 
generator for me, ignoring the masking (as a nearly-newbie, I can say 
that ignoring the stuff I don't yet care about usually works):
from matplotlib.mlab import csv2rec, csv
import pylab as p
import numpy as n
names = ('date', 'time', 'program', 'level', 'error_id', 'thread', 
'na', 'machine', 'request', 'detail')
r = csv2rec("/Users/clew/Documents/pycode/test.csv", names = names)
print r.shape
print r[3]
for name in names:
 print 'Values of ', name, ':'
 print r[name]
for row in r:
 if row['thread'] == 537: print row
print type(r['thread'])
n, bins, patches = p.hist(r['thread'])
print n,bins,patches
p.savefig('csvhistogram')
p.show()
Does this work for you? On the whole file?
&C
On Aug 21, 2009, at 9:27 AM, Phil Robare wrote:
> Hi folks,
>
> I have a (newbie) problem using csv2rec. I am a regular python user
> but this is my first time using matplotlib and numpy after being
> inspired by attending a talk by Dr. John Hunter.
>
> I am trying to read a csv file that has >6000 lines that look like 
> this:
>
> <code>
> 8/17/2009,4:49:52
> PM,CVAgent,Information,5,537,N/A,THP-PR-APVL,F: 
> 20090210::7881558:3893255:311247:166422::,Completed..
> 8/17/2009,4:49:52
> PM,CVAgent,Information,3,537,N/A,THP-PR-APVL,F: 
> 20090210::7881558:3888955:311247:166422::,From
> Disk..
> 8/17/2009,4:49:51 PM,CVAgent,Warning,8,556,N/A,THP-PR-APVL,Exception
> in CVProcess.GetNewfile: The process cannot access the file because it
> is being used by another process..,
> 8/17/2009,4:49:51 PM,CVAgent,Information,2,447,N/A,THP-PR-APVL,SDAY ->
> R: 
> 20090210 
> :::3893955:311247:166422::20090210:::3893955:388247:166422::50:,.
> 8/17/2009,4:29:55
> PM,CVAgent,Information,5,537,N/A,THP-PR-APVL,F: 
> 20090728::7881558:4888461:22088980:964878::,Completed..
> 8/17/2009,4:29:55
> PM,CVAgent,Information,3,537,N/A,THP-PR-APVL,F: 
> 20090728::7881558:4888461:22030980:964878::,From
> Disk..
> 8/17/2009,4:29:54 PM,CVAgent,Information,2,3045,N/A,THP-PR-APVL,JJULIO
> -> R: 
> 20090728 
> :::4888461:22030980:964878::20090728:::4888461:22030980:964878::50:,.
> 8/17/2009,4:24:02
> PM,CVAgent,Information,5,537,N/A,THP-PR-APVL,F: 
> 20090226::7881558:2882501:325032:316888::,Completed..
> 8/17/2009,4:24:02
> PM,CVAgent,Information,3,537,N/A,THP-PR-APVL,F: 
> 20090226::7881558:8822501:325882:318816::,From
> Disk..
> 8/17/2009,4:23:56 PM,CVAgent,Information,2,556,N/A,THP-PR-APVL,tdietz
> -> R:20090226::::325882:318816::20090226::::325882:318816::50:,.
> 8/17/2009,4:21:41 PM,CVAgent,Information,2,3045,N/A,THP-PR-APVL,tdietz
> -> R:20090226::::325882:318816::20090226::::325032:318816::50:,.
> 8/17/2009,4:19:44
> PM,CVAgent,Information,5,537,N/A,THP-PR-APVL,F: 
> 20090210::7881558:2882613:278887:4020000::,Completed..
> 8/17/2009,4:19:43
> PM,CVAgent,Information,3,537,N/A,THP-PR-APVL,F: 
> 20090210::7881558:2882613:278777:4020000::,From
> Disk..
> 8/17/2009,4:19:42 PM,CVAgent,Information,2,793,N/A,THP-PR-APVL,MUTSCH
> -> R: 
> 20090210 
> :::2882613:278887:4020000::20090210:::2882613:278887:4020000::50:,.
> 8/17/2009,4:11:02
> PM,CVAgent,Information,5,793,N/A,THP-PR-APVL,F: 
> 20090817::7881558:1776517:1211:58800::,Completed..
> 8/17/2009,4:49:52
> PM,CVAgent,Information,5,537,N/A,THP-PR-APVL,F: 
> 20090210::7881558:3893255:311247:166422::,Completed..
> </code>
>
> I have given the columns names since there is not a header line:
> <code>
> In [150]: print names
> ('date', 'time', 'program', 'level', 'error_id', 'thread', 'na',
> 'machine', 'request', 'detail')
> </code>
>
> and I have provided convert functions to be sure the data is read 
> correctly:
> <code>
> In [152]: print converterd
> {'thread': <type 'int'>, 'level': <type 'str'>, 'na': <type 'str'>,
> 'request': <type 'str'>, 'detail': <type 'str'>, 'machine': <type
> 'str'>, 'program': <type 'str'>, 'time': <function str2time at
> 0x03795530>, 'date': <function str2date at
> 0x037950B0>}
> </code>
>
> (I'm not sure if this is needed. IPython seems to recognize csv2rec
> just fine but the sample program does an import like this.)
> <code>
> In [141]: import matplotlib.mlab as mlab
> </code>
>
> So now I call csv2rec on my file. It takes a second or so to gulp it
> all in and then returns without error.
> <code>
> In [142]: r=mlab.csv2rec(filename,converterd=converterd,names=names)
> </code>
>
> So now I look to see what I have. And it's nothing like I thought it
> would be. I expected thousands of records and I have 10. I expected
> times and dates, ints and strings. And all I have are masked values.
> <code>
> In [143]: r
> Out[143]:
> masked_records(
> date : [-- -- -- -- -- -- -- -- -- --]
> time : [-- -- -- -- -- -- -- -- -- --]
> program : [-- -- -- -- -- -- -- -- -- --]
> level : [-- -- -- -- -- -- -- -- -- --]
> error_id : [-- -- -- -- -- -- -- -- -- --]
> thread : [-- -- -- -- -- -- -- -- -- --]
> na : [-- -- -- -- -- -- -- -- -- --]
> machine : [-- -- -- -- -- -- -- -- -- --]
> request : [-- -- -- -- -- -- -- -- -- --]
> detail : [-- -- -- -- -- -- -- -- -- --]
> fill_value : ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?')
> )
> </code>
>
> So I look at the mask. I see no clues here.
> <code>
> In [144]: r.mask
> Out[144]:
> array([(True, True, True, True, True, True, True, True, True, True),
> (True, True, True, True, True, True, True, True, True, True),
> (True, True, True, True, True, True, True, True, True, True),
> (True, True, True, True, True, True, True, True, True, True),
> (True, True, True, True, True, True, True, True, True, True),
> (True, True, True, True, True, True, True, True, True, True),
> (True, True, True, True, True, True, True, True, True, True),
> (True, True, True, True, True, True, True, True, True, True),
> (True, True, True, True, True, True, True, True, True, True),
> (True, True, True, True, True, True, True, True, True, True)],
> dtype=[('date', '|b1'), ('time', '|b1'), ('program', '|b1'),
> ('level', '|b1'), ('error_id', '|b1'), ('thread', '|b1'), ('na',
> '|b1'), ('machine', '|b1'),
> ('request', '|b1'), ('detail', '|b1')])
> </code>
>
> Well, maybe if I change the mask I can see what is being hidden.
> <code>
> In [145]: r.mask[0]
> Out[145]: (True, True, True, True, True, True, True, True, True, True)
>
> In [146]: r.mask[0]=(False,)*10
>
> In [147]: r
> Out[147]:
> masked_records(
> date : [2009年08月17日 -- -- -- -- -- -- -- -- --]
> time : [2009年08月17日 -- -- -- -- -- -- -- -- --]
> program : [2009年08月17日 -- -- -- -- -- -- -- -- --]
> level : [2009年08月17日 -- -- -- -- -- -- -- -- --]
> error_id : [2009年08月17日 -- -- -- -- -- -- -- -- --]
> thread : [2009年08月17日 -- -- -- -- -- -- -- -- --]
> na : [2009年08月17日 -- -- -- -- -- -- -- -- --]
> machine : [2009年08月17日 -- -- -- -- -- -- -- -- --]
> request : [2009年08月17日 -- -- -- -- -- -- -- -- --]
> detail : [2009年08月17日 -- -- -- -- -- -- -- -- --]
> fill_value : ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?')
> )
> </code>
>
> So I think I see what is going on. Rather than taking each line of
> the input file as a record it is taking each column as a record.
> Since I said there are ten values per record it stopped after ten rows
> since that is all the columns it had to fill in.
>
> Now you know my problem.
>
> How do I get csv2rec to read my file so I can start getting nice
> histograms of counts per day?
>
> A further question is why am I getting masked records at all and how
> do I control this? I don't see anything in the numpy or matplotlib
> user guides that answer this. I did find a helpful document on the
> web (http://www.bom.gov.au/bmrc/climdyn/staff/lih/pubs/docs/masks.pdf)
> that explained what masks are
> and why and how they can be used. I don't need them and would like to
> make sure that nothing is masked.
>
> Thanks in advance for helping a newbie over the hump.
>
> Phil Robare
>
> ------------------------------------------------------------------------------
> 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
Chloe Lewis
Graduate student, Amundson Lab
Division of Ecosystem Sciences, ESPM
University of California, Berkeley
137 Mulford Hall - #3114
Berkeley, CA 94720-3114
ch...@na...
From: mkoss <Mic...@na...> - 2009年08月21日 17:01:16
Does anyone know how to do a contour plot of a set of X,Y data where each
contour level has the same number of data points inside it? What I want to
show is where most of the data is appearing in the x, y position for a
scatter plot of ~1,000 points, so you can't just plot all those as points. 
This is similar to the probability density function for a scatter plot. 
In concept, you would start at the median of x and median of y and then
include points by their distance from the median until you reach the number
in each contour and draw a contour around this region. Then you would
proceed outward from the contour to find more points.
An alternative, but not exactly correct approach I have already done is to
bin the data like a 2D histogram and then use the number of occurrences in
each bin as the z value for contourf.
I see this plot a lot in the scientific literature, so I know it must be
possible, but haven't been able to find it on the web for python.
Thanks,
Mike
-- 
View this message in context: http://www.nabble.com/Contour-of-Number-of-Occurences-in-a-Scatter-Plot-tp25083681p25083681.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: John H. <jd...@gm...> - 2009年08月21日 16:38:51
On Fri, Aug 21, 2009 at 11:27 AM, Phil Robare<ver...@gm...> wrote:
> I have a (newbie) problem using csv2rec. I am a regular python user
> but this is my first time using matplotlib and numpy after being
> inspired by attending a talk by Dr. John Hunter.
>
> I am trying to read a csv file that has >6000 lines that look like this:
Are you able to post your file somewhere -- publicly if possible (eg
attach it to your response) but offlist if it contains info you would
not like to disseminate widely?
JDH
From: Phil R. <ver...@gm...> - 2009年08月21日 16:27:28
Hi folks,
I have a (newbie) problem using csv2rec. I am a regular python user
but this is my first time using matplotlib and numpy after being
inspired by attending a talk by Dr. John Hunter.
I am trying to read a csv file that has >6000 lines that look like this:
<code>
8/17/2009,4:49:52
PM,CVAgent,Information,5,537,N/A,THP-PR-APVL,F:20090210::7881558:3893255:311247:166422::,Completed..
8/17/2009,4:49:52
PM,CVAgent,Information,3,537,N/A,THP-PR-APVL,F:20090210::7881558:3888955:311247:166422::,From
Disk..
8/17/2009,4:49:51 PM,CVAgent,Warning,8,556,N/A,THP-PR-APVL,Exception
in CVProcess.GetNewfile: The process cannot access the file because it
is being used by another process..,
8/17/2009,4:49:51 PM,CVAgent,Information,2,447,N/A,THP-PR-APVL,SDAY ->
R:20090210:::3893955:311247:166422::20090210:::3893955:388247:166422::50:,.
8/17/2009,4:29:55
PM,CVAgent,Information,5,537,N/A,THP-PR-APVL,F:20090728::7881558:4888461:22088980:964878::,Completed..
8/17/2009,4:29:55
PM,CVAgent,Information,3,537,N/A,THP-PR-APVL,F:20090728::7881558:4888461:22030980:964878::,From
Disk..
8/17/2009,4:29:54 PM,CVAgent,Information,2,3045,N/A,THP-PR-APVL,JJULIO
-> R:20090728:::4888461:22030980:964878::20090728:::4888461:22030980:964878::50:,.
8/17/2009,4:24:02
PM,CVAgent,Information,5,537,N/A,THP-PR-APVL,F:20090226::7881558:2882501:325032:316888::,Completed..
8/17/2009,4:24:02
PM,CVAgent,Information,3,537,N/A,THP-PR-APVL,F:20090226::7881558:8822501:325882:318816::,From
Disk..
8/17/2009,4:23:56 PM,CVAgent,Information,2,556,N/A,THP-PR-APVL,tdietz
-> R:20090226::::325882:318816::20090226::::325882:318816::50:,.
8/17/2009,4:21:41 PM,CVAgent,Information,2,3045,N/A,THP-PR-APVL,tdietz
-> R:20090226::::325882:318816::20090226::::325032:318816::50:,.
8/17/2009,4:19:44
PM,CVAgent,Information,5,537,N/A,THP-PR-APVL,F:20090210::7881558:2882613:278887:4020000::,Completed..
8/17/2009,4:19:43
PM,CVAgent,Information,3,537,N/A,THP-PR-APVL,F:20090210::7881558:2882613:278777:4020000::,From
Disk..
8/17/2009,4:19:42 PM,CVAgent,Information,2,793,N/A,THP-PR-APVL,MUTSCH
-> R:20090210:::2882613:278887:4020000::20090210:::2882613:278887:4020000::50:,.
8/17/2009,4:11:02
PM,CVAgent,Information,5,793,N/A,THP-PR-APVL,F:20090817::7881558:1776517:1211:58800::,Completed..
8/17/2009,4:49:52
PM,CVAgent,Information,5,537,N/A,THP-PR-APVL,F:20090210::7881558:3893255:311247:166422::,Completed..
</code>
I have given the columns names since there is not a header line:
<code>
In [150]: print names
('date', 'time', 'program', 'level', 'error_id', 'thread', 'na',
'machine', 'request', 'detail')
</code>
and I have provided convert functions to be sure the data is read correctly:
<code>
In [152]: print converterd
{'thread': <type 'int'>, 'level': <type 'str'>, 'na': <type 'str'>,
'request': <type 'str'>, 'detail': <type 'str'>, 'machine': <type
'str'>, 'program': <type 'str'>, 'time': <function str2time at
0x03795530>, 'date': <function str2date at
0x037950B0>}
</code>
(I'm not sure if this is needed. IPython seems to recognize csv2rec
just fine but the sample program does an import like this.)
<code>
In [141]: import matplotlib.mlab as mlab
</code>
So now I call csv2rec on my file. It takes a second or so to gulp it
all in and then returns without error.
<code>
In [142]: r=mlab.csv2rec(filename,converterd=converterd,names=names)
</code>
So now I look to see what I have. And it's nothing like I thought it
would be. I expected thousands of records and I have 10. I expected
times and dates, ints and strings. And all I have are masked values.
<code>
In [143]: r
Out[143]:
masked_records(
    date : [-- -- -- -- -- -- -- -- -- --]
    time : [-- -- -- -- -- -- -- -- -- --]
  program : [-- -- -- -- -- -- -- -- -- --]
   level : [-- -- -- -- -- -- -- -- -- --]
  error_id : [-- -- -- -- -- -- -- -- -- --]
   thread : [-- -- -- -- -- -- -- -- -- --]
     na : [-- -- -- -- -- -- -- -- -- --]
  machine : [-- -- -- -- -- -- -- -- -- --]
  request : [-- -- -- -- -- -- -- -- -- --]
   detail : [-- -- -- -- -- -- -- -- -- --]
  fill_value : ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?')
       )
</code>
So I look at the mask. I see no clues here.
<code>
In [144]: r.mask
Out[144]:
array([(True, True, True, True, True, True, True, True, True, True),
   (True, True, True, True, True, True, True, True, True, True),
   (True, True, True, True, True, True, True, True, True, True),
   (True, True, True, True, True, True, True, True, True, True),
   (True, True, True, True, True, True, True, True, True, True),
   (True, True, True, True, True, True, True, True, True, True),
   (True, True, True, True, True, True, True, True, True, True),
   (True, True, True, True, True, True, True, True, True, True),
   (True, True, True, True, True, True, True, True, True, True),
   (True, True, True, True, True, True, True, True, True, True)],
   dtype=[('date', '|b1'), ('time', '|b1'), ('program', '|b1'),
('level', '|b1'), ('error_id', '|b1'), ('thread', '|b1'), ('na',
'|b1'), ('machine', '|b1'),
('request', '|b1'), ('detail', '|b1')])
</code>
Well, maybe if I change the mask I can see what is being hidden.
<code>
In [145]: r.mask[0]
Out[145]: (True, True, True, True, True, True, True, True, True, True)
In [146]: r.mask[0]=(False,)*10
In [147]: r
Out[147]:
masked_records(
    date : [2009年08月17日 -- -- -- -- -- -- -- -- --]
    time : [2009年08月17日 -- -- -- -- -- -- -- -- --]
  program : [2009年08月17日 -- -- -- -- -- -- -- -- --]
   level : [2009年08月17日 -- -- -- -- -- -- -- -- --]
  error_id : [2009年08月17日 -- -- -- -- -- -- -- -- --]
   thread : [2009年08月17日 -- -- -- -- -- -- -- -- --]
     na : [2009年08月17日 -- -- -- -- -- -- -- -- --]
  machine : [2009年08月17日 -- -- -- -- -- -- -- -- --]
  request : [2009年08月17日 -- -- -- -- -- -- -- -- --]
   detail : [2009年08月17日 -- -- -- -- -- -- -- -- --]
  fill_value : ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?')
       )
</code>
So I think I see what is going on. Rather than taking each line of
the input file as a record it is taking each column as a record.
Since I said there are ten values per record it stopped after ten rows
since that is all the columns it had to fill in.
Now you know my problem.
How do I get csv2rec to read my file so I can start getting nice
histograms of counts per day?
A further question is why am I getting masked records at all and how
do I control this? I don't see anything in the numpy or matplotlib
user guides that answer this. I did find a helpful document on the
web (http://www.bom.gov.au/bmrc/climdyn/staff/lih/pubs/docs/masks.pdf)
that explained what masks are
and why and how they can be used. I don't need them and would like to
make sure that nothing is masked.
Thanks in advance for helping a newbie over the hump.
Phil Robare
From: Erik S. <oth...@gm...> - 2009年08月21日 16:12:58
Attachments: success.png fail.png
Hello all,
This may be a difficult post to respond to in the whole, but any
pointers would be appreciated.
My overall goal is to generate contour plots for a wide range of input
data. The data points are not regularly spaced and do not align to
any grid. The data points represent measurements taken from a model
that can take on a variety of shapes. To make matters more difficult,
I'd prefer not to interpolate around corners of the model.
For example ( please forgive the ascii art ):
|-----------------------|
| . . . . . . . .|
| . . . . . . . .|
|----------------| . . .|
 |. .|
 |. . .|
 |------|
In the model above the edges denoted by "|" and "-", data points
denoted by ".". This is a simple L shape with random data points
sampled.
For the most part, the approaches I've taken have worked, but I am
hitting some difficult conditions to debug. Most unnerving are some
artifacts in the plot even though the data values are fairly uniform
(see attached image "fail.png" ).
The general approach I'm taking goes as follows:
1 ) Make a linear space for the x and y components of the data and the
model ( def_points_x is unique and sorted sorted in the code example
):
 # model boundary points x
 x_def = linspace( def_points_x[0], def_points_x[-1],
self.num_points_x ) # do something similar for x and y of data and
model points
2) Triangulate on the points
 try:
 ltri = delaunay.Triangulation( array( xPoints ), array(
yPoints ) ) # xPoints and yPoints are data points
 except:
 ltri = ( None, None, None )
3) use the natural neighbor extrapolator
 if extrapolate:
 # extrapolate
 try:
 interp_extrap = ltri.nn_extrapolator( region_values )
# values for the data points in same order ( i.e., ( xPoints[1],
yPoints[1] ) -> region_values[1] )
 except:
 return ( None, None, None)
4) extrapolate to the model boundary
 x2,y2 = meshgrid( x_def, y_def ) # model boundary region
 z = interp_extrap( x2, y2 )
5) plot the result
 contourf( x_def, y_def, z, linspace( minValue, maxValue,
self.numberOfContourLevels ), zorder = 50, extend = 'both' )
I've attached two images, one showing a nice result and one showing artifacts.
Am I completely off base in this approach, hence I cannot seem to
"perfect" the results? Suggestions?
Thanks for reading!
-Erik
From: Jae-Joon L. <lee...@gm...> - 2009年08月21日 15:38:28
On Fri, Aug 21, 2009 at 10:01 AM, Scott
Sinclair<sco...@gm...> wrote:
>> I just realized that I did not give the correct plot object when creating
>> the colorbar. Now it works perfectly to pass arguments by set_xticklabels().
>>
>> However, another question just arose. To format the numbers on the tick
>> labels I tried to pass a format string when creating the colorbar with the
>> format parameter. But it has no effect. The same when I give a
>> FormatStrFormatter object. I also tried to use
>> cb.ax.axis.set_major_formatter(). The effect of this was. That it sets the
>> labels to the range between 0 and 1. Is there a solution for this problem
>> besides entering the tick labels manually?
The tick locator and tick formatter needs to be passed during the
colorbar creation. Otherwise,
it gets very tricky to deal with. This is because the data coordinate
of the colorbar axes is not directly associated with the ticklabels.
If passing the formatter during the colorbar creation has no effect,
this should be filed as a bug. Please post a small standalone example
that reproduces your problem. Also, please report your version of
matplotlib. If you're using older version, I recommend you to test it
with newer version.
Just in case, my quick test worked fine.
imshow([[1,2],[2,3]])
cb=colorbar(format=r"$%2.1f\%%$")
-JJ
From: Scott S. <sco...@gm...> - 2009年08月21日 14:01:24
> 2009年8月21日 Daniel Platz <mai...@go...>:
> I just realized that I did not give the correct plot object when creating
> the colorbar. Now it works perfectly to pass arguments by set_xticklabels().
>
> However, another question just arose. To format the numbers on the tick
> labels I tried to pass a format string when creating the colorbar with the
> format parameter. But it has no effect. The same when I give a
> FormatStrFormatter object. I also tried to use
> cb.ax.axis.set_major_formatter(). The effect of this was. That it sets the
> labels to the range between 0 and 1. Is there a solution for this problem
> besides entering the tick labels manually?
> Scott Sinclair wrote:
>>>
>>> 2009年8月20日 Daniel Platz <mai...@go...>:
>>> The setting of the new ticklabels works now. But the first label is
>>> attached to the second tick. I tried to adapt the clim range by using
>>> the vmin and vmax option of pcolor but it did not help.
>>
>> Does this help?
>>
>>
>> http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html
Hi Daniel,
It's hard for me to see what's happening here without a simple
standalone code example to illustrate your problem. Trying to
reproduce what you're seeing with a simple example will often reveal
where you're going wrong..
Also note that the default on this mailing list is not to send replies
to the list. Please use "Reply to all" so that your response goes to
the entire list and not directly to me, you're more likely to get a
helpful response that way. I'm sending this to the list, hopefully
someone can help you to resolve the issue.
Cheers,
Scott
From: Werner F. B. <wer...@fr...> - 2009年08月21日 11:02:38
I would like to have the percentage values shown in white instead of in 
black within a pie chart.
I figured I could do something like:
 def reColor(percent):
 "I am lost here on how to format the percentage and change 
the color"
axes.pie(values, labels=labels, autopct=reColor, shadow=False, 
colors=colors)
I thought I could use a mpl.text.Text but I only get the percentage in 
"reColor".
Looked at the gallery and tried to based it on the "barchart_demo2.py" 
example without success. Although would prefer not to have to loop 
through the text.Text instances and figure out which ones are a 
percentage and then color them - but I guess that would be one way of 
doing it but it looks a bit odd to me.
Thanks for any tips
Werner
From: Scott S. <sco...@gm...> - 2009年08月21日 05:40:30
> 2009年8月20日 Daniel Platz <mai...@go...>:
> The setting of the new ticklabels works now. But the first label is
> attached to the second tick. I tried to adapt the clim range by using
> the vmin and vmax option of pcolor but it did not help.
Does this help?
http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html
Cheers,
Scott
> Jouni K. Seppänen wrote:
>> Daniel Platz <mai...@go...> writes:
>>
>>> t = cb4.ax.get_xticklabels()
>>>   for j in t:
>>>     j.set_text(r'$\pi$')
>>>     j.set_fontsize(10)
>>>     j.set_family('serif')
>>
>> Try cb4.ax.set_xticklabels([r'$-\pi$', ...]); draw()
>>
>>> Another problem is that I want to adjust the fontsize of the colorbar
>>> ticklabels on four subplots. This only works for the last two subplots
>>> with the syntax shown above. The same syntax has no effect on the first
>>> two subplots.
>>
>> You should be able to pass font properties to set_xticklabels. If that
>> doesn't work, please post a complete example.

Showing 10 results of 10

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