Re: [Matplotlib-users] dpi

2012-10-12 Thread Nikolaus Rath
Jae-Joon Lee lee.j.joon-re5jqeeqqe8avxtiumw...@public.gmane.org writes:
 On Fri, Oct 12, 2012 at 3:39 AM, Nikolaus Rath 
 nikolaus-bth8mxji...@public.gmane.org wrote:
 matplotlib actually rescales the raw imshow data when saving to a vector
 format? Why is that? I think it should embed the bitmap with full
 resolution in the vector file and rely on the consumer of the vector
 file to scale it to whatever resolution is supported by the display
 device.

 imshow supports interpolation and that's why rasterization comes in.
 If you turn off interpolation (w/ interpolation=none), the original
 image will be embedded. Of course dpi has no meaning in this case.

 However, I agree with you that dpi should be a property of the backend
 only, not the figure. But I am not sure if this can be fixed soon. It
 will be difficult and will take lots of effort I think.

Yeah, that's what I feared. But in the mean time, are there any best
practices to minimize undesired effects like the one above? For example,
are there any other functions that need special parameters to not raster
their output when writing to a vector format? And is there a way to get
a figure on the screen with the right size when I don't know what dpi
the monitor is running with?

Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] dpi

2012-10-11 Thread Nikolaus Rath
Hello,

I'm confused by the dpi property of figures that can be set in
matplotlibrc or passed to pyplot.figure().

It seems to me that dpi is really a property of the backend, not the
figure, and the only place to specify it ought to be when saving into a
bitmap file. 

For example, when showing a figure on the screen, I really want
matplotlib to use the physical dpi of the monitor rather than any
default value. When saving the figure in some vector graphics format, I
don't see what the meaning of the dpi is at all.

Am I missing something?

Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] dpi

2012-10-11 Thread Nikolaus Rath
Damon McDougall damon.mcdougall-re5jqeeqqe8avxtiumw...@public.gmane.org 
writes:
 On Thu, Oct 11, 2012 at 4:00 PM, Nikolaus Rath 
 nikolaus-bth8mxji...@public.gmane.org wrote:
 When saving the figure in some vector graphics format, I
 don't see what the meaning of the dpi is at all.

 Sure, I use `dpi=` all the time for vector formats. Purely because
 when you make calls to `imshow`, you get a rasterised image embedded
 in a figure with vector text and tickmarks and labels, for example.

matplotlib actually rescales the raw imshow data when saving to a vector
format? Why is that? I think it should embed the bitmap with full
resolution in the vector file and rely on the consumer of the vector
file to scale it to whatever resolution is supported by the display
device.


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Corrupted percent signs in labels

2012-10-10 Thread Nikolaus Rath
Benjamin Root ben.root-grryuj3d...@public.gmane.org writes:
  For some reason, my matplotlib isn't able to print percent signs ('%')
  properly:
 
  [1] inspiron:~/tmp# cat mplbug.py
 
  import matplotlib
  import matplotlib.pyplot as plt
  import numpy as np
 
  print matplotlib.__version__
  plt.plot(np.arange(10), np.arange(10)**2)
  plt.xlabel('Percent [%]')
  plt.savefig('mplbug.pdf')
 
  [0] inspiron:~/tmp# python mplbug.py
  1.1.1rc2
 
  I have attached the resulting PDF. For some reason, the slash in the
  percent sign becomes a triangle that partially covers the upper left
  circle.
 
  Known bug? Any workarounds that don't require upgrading (I'd like to
  stick with the Debian package)?
 
  I'm using the AGG backend and saving to a png file without any
  problems, but I'm using the current git master branch. I'll try to see
  if I can recreate on 1.1.1rc2. Watch this space.
 
  No dice. I still can't recreate your problem on OS X 10.7.4 with
  matplotlib version 1.1.1-rc2.
 
  What are your font/tex specifications in the matplotlib.rcParams
 dictionary?

 For me the problem occurs with PDF files, not PNG files. Or was that
 just a typo?

 Font specifications are all default.

 # python -c 'import matplotlib; import pprint;
 # pprint.pprint(matplotlib.rcParams)' | egrep 'tex'
  'legend.handletextpad': 0.8,
  'mathtext.bf': 'serif:bold',
  'mathtext.cal': 'cursive',
  'mathtext.default': 'it',
  'mathtext.fallback_to_cm': True,
  'mathtext.fontset': 'cm',
  'mathtext.it': 'serif:italic',
  'mathtext.rm': 'serif',
  'mathtext.sf': 'sans\\-serif',
  'mathtext.tt': 'monospace',
  'text.antialiased': True,
  'text.color': 'k',
  'text.dvipnghack': None,
  'text.hinting': True,
  'text.latex.preamble': [''],
  'text.latex.preview': False,
  'text.latex.unicode': False,
  'text.usetex': False,

 I think I know why this is happening.  Iirc, we recently took on a patch to
 allow string formatting for labels.  For most cases, it shouldn't effect
 anybody, but if there is a lonely percent sign, I would imagine it could
 cause issues.  As a test, try a double percent sign '%%'.  If that works,
 the my theory might be right.


Nope, using '%%' just results in two corrupted signs in the PDF.


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Corrupted percent signs in labels

2012-10-10 Thread Nikolaus Rath
Michael Droettboom mdroe-pfb3ainihtehxe+lvdl...@public.gmane.org writes:
 For some reason, my matplotlib isn't able to print percent signs ('%')
 properly:

 It's a known bug, fixed since 1.1.1.

 https://github.com/matplotlib/matplotlib/issues/1211

Indeed. Luckily 1.2.0~rc2-1 is in experimental, and upgrading fixed the
problem. Thanks!

Now the only question that remains is: why doesn't github find this
issue when I search for '%'?

 BTW: If you're running the Debian package, how come the version is a
 release candidate? (1.1.1rc2)

Not sure what you mean, why shouldn't it?


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Corrupted percent signs in labels

2012-10-09 Thread Nikolaus Rath
Hello,

For some reason, my matplotlib isn't able to print percent signs ('%')
properly:

[1] inspiron:~/tmp# cat mplbug.py 

import matplotlib
import matplotlib.pyplot as plt
import numpy as np

print matplotlib.__version__
plt.plot(np.arange(10), np.arange(10)**2)
plt.xlabel('Percent [%]')
plt.savefig('mplbug.pdf')

[0] inspiron:~/tmp# python mplbug.py 
1.1.1rc2

I have attached the resulting PDF. For some reason, the slash in the
percent sign becomes a triangle that partially covers the upper left
circle.

Known bug? Any workarounds that don't require upgrading (I'd like to
stick with the Debian package)?


Thanks,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C


mplbug.pdf
Description: Adobe PDF document
--
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Corrupted percent signs in labels

2012-10-09 Thread Nikolaus Rath
Damon McDougall damon.mcdougall-re5jqeeqqe8avxtiumw...@public.gmane.org 
writes:
 On Tue, Oct 9, 2012 at 10:56 PM, Damon McDougall
 damon.mcdougall-re5jqeeqqe8avxtiumw...@public.gmane.org wrote:
 On Tue, Oct 9, 2012 at 10:32 PM, Nikolaus Rath 
 nikolaus-bth8mxji...@public.gmane.org wrote:
 Hello,

 For some reason, my matplotlib isn't able to print percent signs ('%')
 properly:

 [1] inspiron:~/tmp# cat mplbug.py

 import matplotlib
 import matplotlib.pyplot as plt
 import numpy as np

 print matplotlib.__version__
 plt.plot(np.arange(10), np.arange(10)**2)
 plt.xlabel('Percent [%]')
 plt.savefig('mplbug.pdf')

 [0] inspiron:~/tmp# python mplbug.py
 1.1.1rc2

 I have attached the resulting PDF. For some reason, the slash in the
 percent sign becomes a triangle that partially covers the upper left
 circle.

 Known bug? Any workarounds that don't require upgrading (I'd like to
 stick with the Debian package)?

 I'm using the AGG backend and saving to a png file without any
 problems, but I'm using the current git master branch. I'll try to see
 if I can recreate on 1.1.1rc2. Watch this space.

 No dice. I still can't recreate your problem on OS X 10.7.4 with
 matplotlib version 1.1.1-rc2.

 What are your font/tex specifications in the matplotlib.rcParams dictionary?

For me the problem occurs with PDF files, not PNG files. Or was that
just a typo?

Font specifications are all default. 

# python -c 'import matplotlib; import pprint;
# pprint.pprint(matplotlib.rcParams)' | egrep 'tex'
 'legend.handletextpad': 0.8,
 'mathtext.bf': 'serif:bold',
 'mathtext.cal': 'cursive',
 'mathtext.default': 'it',
 'mathtext.fallback_to_cm': True,
 'mathtext.fontset': 'cm',
 'mathtext.it': 'serif:italic',
 'mathtext.rm': 'serif',
 'mathtext.sf': 'sans\\-serif',
 'mathtext.tt': 'monospace',
 'text.antialiased': True,
 'text.color': 'k',
 'text.dvipnghack': None,
 'text.hinting': True,
 'text.latex.preamble': [''],
 'text.latex.preview': False,
 'text.latex.unicode': False,
 'text.usetex': False,

Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Using object oriented interface in interactive mode?

2012-08-05 Thread Nikolaus Rath
Hello,

The following code shows the plot right away as expected:

# python
Python 2.7.3rc2 (default, Apr 22 2012, 22:30:17) 
[GCC 4.6.3] on linux2
Type help, copyright, credits or license for more information.
 import matplotlib
 matplotlib.__version__
'1.1.1rc2'
 import matplotlib.pyplot as plt
 plt.interactive(True)
 plt.plot(range(10))
[matplotlib.lines.Line2D object at 0x2ce7790]


This, however, opens a window but the graph never shows up:

# python
Python 2.7.3rc2 (default, Apr 22 2012, 22:30:17) 
[GCC 4.6.3] on linux2
Type help, copyright, credits or license for more information.
 import matplotlib.pyplot as plt
 plt.interactive(True)
 fig = plt.figure()
 ax = fig.add_subplot(1,1,1)
 ax.plot(range(10))
[matplotlib.lines.Line2D object at 0x3055d90]
 

Does interactive mode only apply to the plot commands in pyplot?

Is there a method I can call in this case to refresh the window and
show the plot?

For seem reason, calling plt.axes() has the desired effect, but this is
probably a side effect that I really should not rely on, right?


Thanks!

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Using object oriented interface in interactive mode?

2012-08-05 Thread Nikolaus Rath
Benjamin Root ben.root-grryuj3d...@public.gmane.org writes:
 On Sunday, August 5, 2012, Nikolaus Rath wrote:

 Hello,

 The following code shows the plot right away as expected:

 # python
 Python 2.7.3rc2 (default, Apr 22 2012, 22:30:17)
 [GCC 4.6.3] on linux2
 Type help, copyright, credits or license for more information.
  import matplotlib
  matplotlib.__version__
 '1.1.1rc2'
  import matplotlib.pyplot as plt
  plt.interactive(True)
  plt.plot(range(10))
 [matplotlib.lines.Line2D object at 0x2ce7790]


 This, however, opens a window but the graph never shows up:

 # python
 Python 2.7.3rc2 (default, Apr 22 2012, 22:30:17)
 [GCC 4.6.3] on linux2
 Type help, copyright, credits or license for more information.
  import matplotlib.pyplot as plt
  plt.interactive(True)
  fig = plt.figure()
  ax = fig.add_subplot(1,1,1)
  ax.plot(range(10))
 [matplotlib.lines.Line2D object at 0x3055d90]
 

 Does interactive mode only apply to the plot commands in pyplot?

 Is there a method I can call in this case to refresh the window and
 show the plot?

 For seem reason, calling plt.axes() has the desired effect, but this is
 probably a side effect that I really should not rely on, right?

 Correct, I think you want plt.draw().

Thanks, that works! But why is it necessary? Does interactive mode only
apply to direct pyplot.* commands?


Thanks,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How to remove vertical lines when plotting rotating phase

2012-04-04 Thread Nikolaus Rath
Hello,

I'm plotting a rotating phase:

# ipython --pylab
x1 = linspace(0, 2*pi, 30)
x = concatenate((x1,x1,x1,x1))
plot(x)

The resulting plot has ugly vertical lines whenever x wraps from 2*pi
back to zero.

Does someone have a nice, general way to get to get rid of such lines?

(the actual data is of course less predictable and regular than the
example above).


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Setting tick labels for matshow

2010-11-04 Thread Nikolaus Rath
Stan West stan.west-qqjzlxdiqip5oiiguju...@public.gmane.org writes:
 From: Nikolaus Rath [mailto:nikolaus-bth8mxji...@public.gmane.org] 
 Sent: Tuesday, November 02, 2010 21:38
 
 In [16]: matplotlib.__version__
 Out[16]: '1.0.0'
 
 I attached the result of fig.savefig(). Let's see if it makes 
 it through
 the list.

 The bug in question was fixed at revision 8652, after 1.0.0 was released.  The
 distinction between the x and y axes in your case is because the y axis is
 inverted.

 You can work around the bug by avoiding the Axes.set_xticks() and set_yticks()

[...]
 I hope that helps.

It does, thanks!



   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book Blueprint to a 
Billion shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Shadowed Text?

2010-11-02 Thread Nikolaus Rath
Hello,

I am placing a text object in a place where the background is sometimes
dark and sometimes light, so the text is hard to see. Adding a
background to the text object itself looks a bit ugly, so I am wondering
if there is a way to add a shadow to the text itself.

What's the best way to do this?

I thought about redrawing the same text just offset by a fraction of the
text size, but I can't quite figure out how to do the placement
properly. My rough idea is the get the position of the text in pixel
coordinates, add an offset to it and then position it with display
coordinates as well. But how do I get the display coordinates of
something that I placed in axes coordinates? And how to I determine how
many pixels I need to offset without knowing the dpi?


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Achieve Improved Network Security with IP and DNS Reputation.
Defend against bad network traffic, including botnets, malware, 
phishing sites, and compromised hosts - saving your company time, 
money, and embarrassment.   Learn More! 
http://p.sf.net/sfu/hpdev2dev-nov
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Setting tick labels for matshow

2010-10-30 Thread Nikolaus Rath
Hello,

I am trying to set tick labels for a matshow plot. This works just fine
if I only work on the X axis:

res = np.diag(np.arange(10)) # dummy data
modes = [ (x+1, 0) for x in range(5) ] # dummy data

fig = plt.figure()
ax = fig.add_subplot(111)
cs = ax.matshow(res)
fig.colorbar(cs, ticks=np.arange(0,-10,-1), shrink=0.8)
ax.set_xticklabels(['%d/%d' % (x[1], x[0]) for x in modes])
ax.set_xticks(2*np.arange(len(modes))+0.5)

but if I try to do the same think with the Y axis, everything looks
messed up (e.g. the matrix is no longer square):

ax.set_yticklabels(['%d/%d' % (x[1], x[0]) for x in modes])
ax.set_yticks(2*np.arange(len(modes))+0.5)



What am I doing wrong?


Thanks,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Trouble with contour plot

2010-10-29 Thread Nikolaus Rath
Benjamin Root ben.root-grryuj3d...@public.gmane.org writes:
 On Thu, Oct 28, 2010 at 3:31 PM, Nikolaus Rath 
 nikolaus-bth8mxji...@public.gmane.org wrote:

 Hello,

 I'm having a weird problem with a contour plot. Consider the following
 plots:

 import cPickle as pickle
 import matplotlib.pyplot as plt
 (Theta, Phi, Bnormal) = pickle.load(open('trouble.pickle', 'rb'))
 plt.figure(0)
 for i in [0, 300]:
plt.plot(Theta, Bnormal[:, i], label='Bnormal at Phi=%.3g' % Phi[i])

 plt.ylabel('Theta')
 plt.legend()
 plt.savefig('figure0.png')
 plt.figure(1)
 plt.contourf(Phi, Theta, Bnormal)
 plt.xlabel('Phi')
 plt.ylabel('Theta')
 plt.colorbar()
 plt.savefig('figure1.png')

 The 'trouble.pickle' file is available on
 http://www.rath.org/trouble.pickle. At Phi=0 the contour plot agrees
 with the crossection (both show an n=7 oscillation), but at Phi=1.68 the
 contour plot shows a uniform value while the crossection shows a phase
 shifted version of oscillation at Phi=0.

 It seems to me that this is a blatant contradiction.


 I have also uploaded the two figures at http://www.rath.org/figure1.png
 and http://www.rath.org/figure0.png.


 Am I missing something, or is this a bug?

 $ python --version
 Python 2.6.5
 $ python -c 'import matplotlib; print matplotlib.__version__'
 1.0.0


 Thanks,

   -Nikolaus


 Nikolaus,

 What might be happening is that the Theta variable isn't monotonic.  It
 first goes from zero to pi, then from -pi to 0.  This also explains the odd
 lines that appear in the line plots at the top and bottom.  Try reforming
 your arrays so that the domain is monotonic (note that you will have to
 adjust the Phi and the Bnormal arrays as well because they were arranged
 assuming a certain domain from Theta.

Indeed, this was the problem. Thank you very much!


However, it seems to me that this is quite a serious bug. The contour
documentation on
http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.contour
does not mention this requirement, and obviously the contour method
itself does not even bother to check if its arguments are monotonically
increasing. Instead, it just *silently* produces garbage that in some
cases even looks like plausible data(!).

Am I missing something here? Otherwise I'll report this on the bug
tracker. I think this should be documented and contour() should check
its input and raise a ValueError if it's not monotonic.



Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Trouble with contour plot

2010-10-29 Thread Nikolaus Rath
Benjamin Root ben.root-grryuj3d...@public.gmane.org writes:
 However, it seems to me that this is quite a serious bug. The contour
 documentation on

 http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.contour
 does not mention this requirement, and obviously the contour method
 itself does not even bother to check if its arguments are monotonically
 increasing. Instead, it just *silently* produces garbage that in some
 cases even looks like plausible data(!).

 Am I missing something here? Otherwise I'll report this on the bug
 tracker. I think this should be documented and contour() should check
 its input and raise a ValueError if it's not monotonic.

 You are right, the documentation is seriously lacking and woefully
 out-of-date.  It still claims that it can not handle internal regions
 correctly with masked arrays (I am pretty sure that is fixed) and it says
 nothing of any characteristics of X and Y.

I see. I added this issue to the bug tracker so that it doesn't get
forgotten.

 I don't know if there are any strict requirement on monotonicity for X and
 Y, or if there are any cases where the plot is still valid even if that
 property is violated.  If it is a requirement, then I agree that there
 should be a check.

How can it not be a requirement if the output is wrong in some cases? It
does not matter if there are also cases where it works - you would never
be able to trust any plot you generate.

 P.S. - I find that in many cases, contourf() is the wrong function to use
 for such plots, and find pcolor() (or one of its variants) to be better
 suited.  Don't know what is better for you in your case, but it might be
 something to investigate.

Thanks for the hint, looks interesting. I looked at the documentation, but I 
don't really
understand the difference between pcolor and pcolormesh. Could you
elaborate on that?


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Trouble with contour plot

2010-10-29 Thread Nikolaus Rath
Eric Firing efiring-msmayosy5ky3upmlikx...@public.gmane.org writes:
 I don't know if there are any strict requirement on monotonicity for X
 and Y, or if there are any cases where the plot is still valid even if
 that property is violated.  If it is a requirement, then I agree that
 there should be a check.

 For sensible output, it is a requirement.  Contour and contourf (like 
 imshow, pcolor, and pcolormesh) work with gridded data.  Gridding is the 
 responsibility of the user.  It can be done in many different ways, so 
 it makes sense to keep the gridding separate from the display of the 
 gridded data.

 If there is a check--and I am not convinced there should be--it should 
 provide only a warning.  It is perfectly reasonable for a person to take 
 a dataset and contour it even if the grid is not monotonic.  Sometimes 
 one wants to get a quick look at raw input, complete with errors.


I don't quite understand your last point. In my example, the
single jump from pi to -pi makes half of the plot constant while in
truth it is oscillatory. I would not say that this reflects the raw
input in any way, and I am not sure what one could learn from this plot
with a quick (or even prolonged) look.

Am I missing something? Is there some obvious connection between the
jump in Theta, the data, and the resulting plot? To me the plot looks
like unpredictable garbage, so I really don't understand how anyone
could want to do something like that...


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Trouble with contour plot

2010-10-28 Thread Nikolaus Rath
Hello,

I'm having a weird problem with a contour plot. Consider the following
plots:

import cPickle as pickle
import matplotlib.pyplot as plt
(Theta, Phi, Bnormal) = pickle.load(open('trouble.pickle', 'rb'))
plt.figure(0)
for i in [0, 300]:
plt.plot(Theta, Bnormal[:, i], label='Bnormal at Phi=%.3g' % Phi[i])

plt.ylabel('Theta')
plt.legend()
plt.savefig('figure0.png')
plt.figure(1)
plt.contourf(Phi, Theta, Bnormal)
plt.xlabel('Phi')
plt.ylabel('Theta')
plt.colorbar()
plt.savefig('figure1.png')

The 'trouble.pickle' file is available on
http://www.rath.org/trouble.pickle. At Phi=0 the contour plot agrees
with the crossection (both show an n=7 oscillation), but at Phi=1.68 the
contour plot shows a uniform value while the crossection shows a phase
shifted version of oscillation at Phi=0.

It seems to me that this is a blatant contradiction.


I have also uploaded the two figures at http://www.rath.org/figure1.png
and http://www.rath.org/figure0.png.


Am I missing something, or is this a bug?

$ python --version
Python 2.6.5
$ python -c 'import matplotlib; print matplotlib.__version__'
1.0.0


Thanks,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] GridSpec Index Order

2010-10-25 Thread Nikolaus Rath
Hello,

I just noticed that in order to get a 3 row by 4 column grid, I have to
do

import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec

def make_ticklabels_invisible(fig):
for i, ax in enumerate(fig.axes):
ax.text(0.5, 0.5, ax%d % (i+1), va=center, ha=center)
for tl in ax.get_xticklabels() + ax.get_yticklabels():
tl.set_visible(False)

plt.figure()

gs = GridSpec(3, 4)

for i in range(4):
for j in range(3):
plt.subplot(gs[i, j])

plt.suptitle(GridSpec)
make_ticklabels_invisible(plt.gcf())
plt.show()


So I have to instantiate GridSpec with a (rows, column), but when I
index the grid I have to use (column, row).

Is there any reason for this counterintuitive behaviour?


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] GridSpec Index Order

2010-10-25 Thread Nikolaus Rath
On 10/25/2010 11:18 AM, Jae-Joon Lee wrote:
 On Mon, Oct 25, 2010 at 10:45 PM, Nikolaus Rath nikol...@rath.org wrote:
 So I have to instantiate GridSpec with a (rows, column), but when I
 index the grid I have to use (column, row).

 Is there any reason for this counterintuitive behaviour?

 
 This is not an intended behavior but a bug which affects a grid of
 non-square shape.
 This has been fixed in the svn version.
 
 Meanwhile, you may use 1-d indexing. e.g.,
 
 import matplotlib.pyplot as plt
 from matplotlib.gridspec import GridSpec
 
 gs = GridSpec(3, 4)
 
 for irow in range(3):
 for icol in range(4):
 ax = plt.subplot(gs[irow*4+icol])

I see, thanks. Is there also a way to use this workaround for slices? I
want a subplot in column 4 that spans all rows...


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] GridSpec for Figure objects?

2010-10-24 Thread Nikolaus Rath
Hello,

I would like to create subplots with different sizes using the object
oriented API. However, it seems that the subplot2grid() method exists
only in pyplot, but not as a Figure instance method. Am I looking in the
wrong place? How do I use subplot2grid with an existing Figure object?


Thanks,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Same X and Y scale

2010-07-30 Thread Nikolaus Rath
Ryan May rmay31-re5jqeeqqe8avxtiumw...@public.gmane.org writes:
 On Jul 30, 2010, at 14:34, Nikolaus Rath 
 nikolaus-bth8mxji...@public.gmane.org wrote:

 Hi,
 
 Consider this:
 
 X = np.linspace(0.70, 1.1, 100)
 Y = np.linspace(-1.19, 1.19, 70)
 (Xs, Ys) = np.meshgrid(X, Y)
 Z = np.sqrt((Xs-0.9)**2 + Ys**2) - 0.10
 fig = plt.figure()
 ax = fig.add_subplot(111)
 ax.contour(X, Y, Z)
 fig.show()
 
 This works, but gives the y axis a different scale than the x axis so
 the ellipses look like circles.
 
 How can I get the same scale for the x- and y-axis?
 
 I tried to set ax.set_autoscale_on(False), but that resulted in a
 totally different part of the coordinate system being 

 Try:

 ax.set_aspect('equal')

Works perfectly, thanks!


   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Contour plot of non-uniformly sampled data

2010-07-29 Thread Nikolaus Rath
Jeff Whitaker jswhit-97jfqw80gc6171pxa8y...@public.gmane.org writes:
 On 7/28/10 8:32 PM, Nikolaus Rath wrote:
 Hello,

 What is the best way to generate a contour plot from a set of
 non-uniformly sampled data (i.e., the datapoints do not lie on the
 points of a rectangular grid but are randomly distributed)?


 Thanks,

 -Nikolaus


 Nikolaus: You can either use mlab.griddata to interpolate the data to a 
 regular grid, or use pyplot.tricontour to perform a delaunay 
 triangulation and contour the resulting triangle values.

Fantastic, thanks!


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Contour plot of non-uniformly sampled data

2010-07-28 Thread Nikolaus Rath
Hello,

What is the best way to generate a contour plot from a set of
non-uniformly sampled data (i.e., the datapoints do not lie on the
points of a rectangular grid but are randomly distributed)?


Thanks,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Contour plots with same color mapping

2010-07-26 Thread Nikolaus Rath
Hello,

I would like to draw a couple of contour plots. The plots are on
separate figures, but they should all have exactly the same color
mapping (i.e, the same Z value should correspond to the same color in
all plots).

What's the best way to achieve this?

From the documentation I gather that I should use the norm and extend
keyword arguments, but I wasn't really able to figure out what values
I have to pass and how the matplotlib.colors.Normalize instance works.


Thanks,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share 
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Plotting irregular 2d data

2010-06-08 Thread Nikolaus Rath
Hi,

I have a 1d array Z that unfortunately contains information about a two
dimensional surface. The mapping is nontrivial (i.e. Z is not just a
sequence of column or row information that I could reshape) but
homogenous (i.e. there is a rectangular grid and Z contains data for
each vertex). The x and y coordinates for each datapoint in Z are
contained in separate arrays X and Y.

A simple pyplot.contour(X, Y, Z) refuses to plot the data because Z is
not 2d (TypeError: Input z must be a 2D array).

What's the best way to plot this data?

Is there an easy way to reshuffle the elements of Z so that they are in
either row-column or column-row order?


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Plotting 2d fourier amplitudes

2010-04-26 Thread Nikolaus Rath
Hello,

I have 2d array with fourier amplitudes that I would like to plot. I
found two options: contourf and imshow. This is my code:

omega = np.fft.rfftn(b_field, axes=(1, 0))
omega = np.abs(np.fft.fftshift(omega, axes=(1,)))
fig = plt.figure()
ax = fig.add_subplot(111)
M = omega.shape[0]
N = omega.shape[1]
ax.set_title('Spectrum')
ax.set_ylabel(r'Poloidal Mode Number m')
ax.set_xlabel(r'Toroidal Mode Number n')
ax.grid(True)

# Get rid of normalization
omega /= np.prod(omega.shape)

The problem with contourf is that I can't seem to stop it from
strongly interpolating the data, which obscures the discrete nature:
(see www.rath.org/contourf.png)

ctr = ax.contourf(np.arange(-N / 2, N / 2),
  np.arange(0, M),
  omega * 1, 100, cmap=cm.YlOrRd, 
interpolation='nearest')
fig.colorbar(ctr)
ax.set_xlim(xmin= -(N - 1) / 2, xmax=(N - 1) / 2)
ax.set_ylim(ymin=0, ymax=M - 1)
fig.show()

Apparently contourf does not accept the interpolation='nearest' option.
Is there a way to make it stop interpolating?

The problem with imshow is, that it rescales the data so the
colorbar does not show the correct amplitudes (see
www.rath.org/imshow.png):

ctr = ax.imshow(omega, cmap=cm.YlOrRd, aspect='equal', 
interpolation='nearest',
origin='lower', extent=(-(N-1)/2, (N-1)/2, 0, M-1))
fig.colorbar(ctr)
ax.set_xlim(xmin= -(N - 1) / 2, xmax=(N - 1) / 2)
ax.set_ylim(ymin=0, ymax=M - 1)
fig.show()

Is there a way to get the proper amplitudes into the colorbar?


Thanks!


   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Plotting 2d fourier amplitudes

2010-04-26 Thread Nikolaus Rath
Hi,

I want the colorbar to show the real fourier amplitudes, not the
amplitudes after rescaling to 0..1. In other words: the colorbar created
by imshow should have the same values as the one created by contourf.

I am not sure how I can use vmin and vmax to achieve that effect. The
scaling is done correctly, it's just that the colorbar should show the
original, and not the rescaled values.

Thanks,
-Niko


I did not try vmin and vmax, because
On 04/26/2010 02:31 PM, Jae-Joon Lee wrote:
 Did you try to change vmin, vmax?
 
 http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.imshow
 
 If this is not what you want, please describe more explicitly why the
 colorbar is wrong.
 
 Regards,
 
 -JJ
 
 
 On Mon, Apr 26, 2010 at 11:37 AM, Nikolaus Rath nikol...@rath.org wrote:
 The problem with imshow is, that it rescales the data so the
 colorbar does not show the correct amplitudes (see
 www.rath.org/imshow.png):

ctr = ax.imshow(omega, cmap=cm.YlOrRd, aspect='equal', 
 interpolation='nearest',
origin='lower', extent=(-(N-1)/2, (N-1)/2, 0, M-1))
fig.colorbar(ctr)
ax.set_xlim(xmin= -(N - 1) / 2, xmax=(N - 1) / 2)
ax.set_ylim(ymin=0, ymax=M - 1)
fig.show()

 Is there a way to get the proper amplitudes into the colorbar?


   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Plotting 2d fourier amplitudes

2010-04-26 Thread Nikolaus Rath
Hi,

Believe it or not, the factor of 1 was my only problem all the time.
Until you pointed it out I never noticed that it was missing in one of
the calls.


Thanks!
Niko


On 04/26/2010 03:26 PM, Jae-Joon Lee wrote:
 I think I'm lost.
 
 
  In other words: the colorbar created
 by imshow should have the same values as the one created by contourf.
 
 But, in your original post, your plotting two different image.
 with contourf, you're drawing omega*1, but with imshow, you're
 drawing omega.
 Are you saying that these two should have same colorbar, although
 there is a factor 1 difference?
 
 And, as far as I know, colorbar shows values of the original input.
 
 What is the min and max of omega, and what do you expect your colorbar show?
 If possible, please post a complete example so that others can test.
 
 Regards,
 
 -JJ
 
 

 I am not sure how I can use vmin and vmax to achieve that effect. The
 scaling is done correctly, it's just that the colorbar should show the
 original, and not the rescaled values.

 Thanks,
 -Niko


 I did not try vmin and vmax, because
 On 04/26/2010 02:31 PM, Jae-Joon Lee wrote:
 Did you try to change vmin, vmax?

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

 If this is not what you want, please describe more explicitly why the
 colorbar is wrong.

 Regards,

 -JJ


 On Mon, Apr 26, 2010 at 11:37 AM, Nikolaus Rath nikol...@rath.org wrote:
 The problem with imshow is, that it rescales the data so the
 colorbar does not show the correct amplitudes (see
 www.rath.org/imshow.png):

ctr = ax.imshow(omega, cmap=cm.YlOrRd, aspect='equal', 
 interpolation='nearest',
origin='lower', extent=(-(N-1)/2, (N-1)/2, 0, M-1))
fig.colorbar(ctr)
ax.set_xlim(xmin= -(N - 1) / 2, xmax=(N - 1) / 2)
ax.set_ylim(ymin=0, ymax=M - 1)
fig.show()

 Is there a way to get the proper amplitudes into the colorbar?


   -Nikolaus

 --
  »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C



   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How to show interactive plot window from program

2010-04-20 Thread Nikolaus Rath
Hello,

When I'm calling the pyplot.plot function from ipython, I get a nice
dialog in which I can zoom, pan  save.

How can I achieve the same thing from a non-interactive program?

I tried

fig = plt.figure()
ax = fig.add_subplot(111)
ax.contourf(stuff)
fig.show()

but this program terminates without showing anything. Is there a
function that I can call that shows up the interactive window and only
returns once I close the window?


Thanks,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] ticks at 0 and 2pi

2010-04-20 Thread Nikolaus Rath
Hello,

I'm trying to plot something from 0 to 2pi:

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title('Radial Magnetic Field')
ax.set_ylabel(r'Poloidal Angle $\theta$')
ax.set_xlabel(r'Toroidal Angle $\phi$')

ax.set_xticks([0, 2 * math.pi])
ax.set_xticklabels(['0', r'$2\pi$'])
ax.set_yticklabels([r'$-\pi$', r'$\pi$'])
ax.set_yticks([-math.pi, math.pi])

ax.set_xlim(xmin=0, xmax=2 * math.pi)
ax.set_ylim(ymin= -math.pi, ymax=math.pi)

But unfortunately the ticks for x=2pi and y=pi are not shown. They do
show up if I move them a tiny bit:

ax.set_xticks([0, 2 * math.pi * 0.98])
ax.set_yticks([-math.pi, math.pi * 0.98])
But obviously this is ugly.

Is there a way to show the labels without moving the to the wrong
position and without extending the axis limits (since that introduces a
white border)?

Best,
   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] ticks at 0 and 2pi

2010-04-20 Thread Nikolaus Rath
On 04/20/2010 10:29 AM, Ryan May wrote:
 On Tue, Apr 20, 2010 at 8:58 AM, Nikolaus Rath nikol...@rath.org wrote:
 Hello,

 I'm trying to plot something from 0 to 2pi:

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title('Radial Magnetic Field')
ax.set_ylabel(r'Poloidal Angle $\theta$')
ax.set_xlabel(r'Toroidal Angle $\phi$')

ax.set_xticks([0, 2 * math.pi])
ax.set_xticklabels(['0', r'$2\pi$'])
ax.set_yticklabels([r'$-\pi$', r'$\pi$'])
ax.set_yticks([-math.pi, math.pi])

ax.set_xlim(xmin=0, xmax=2 * math.pi)
ax.set_ylim(ymin= -math.pi, ymax=math.pi)
 
 I don't see the problem here, I get the ticks as specified.  What
 version of matplotlib are you using? What backend are you using?

Actually, now that I tried it again, it suddenly works. Strange... Sorry
for the pointless mail.


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How to make colormaps

2010-04-20 Thread Nikolaus Rath
Hello,

Maybe my googling skills are deficient, but I wasn't able to find any
information on how to define my own colormap.

Can someone give me a pointer, or a basic example how to create a simple
map that e.g. maps -1 to Red, 0 to White, and 1 to Blue?

Thanks,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to make colormaps

2010-04-20 Thread Nikolaus Rath
On 04/20/2010 01:06 PM, Ryan May wrote:
 On Tue, Apr 20, 2010 at 11:40 AM, Jim Vickroy jim.vick...@noaa.gov wrote:
 Nikolaus Rath wrote:

 Hello,

 Maybe my googling skills are deficient, but I wasn't able to find any
 information on how to define my own colormap.

 Can someone give me a pointer, or a basic example how to create a simple
 map that e.g. maps -1 to Red, 0 to White, and 1 to Blue?

 http://lmgtfy.com/?q=matplotlib+colormaps
 
 That was a tad harsh, given that the first page of google results
 didn't really answer the question. (If you're going to be snarky, at
 least make sure you're right.)

Don't worry, I'm usually worse myself. And his answer did help me. I
actually googled the same query, but I skipped over the first two
matches after reading the title since I thought they'd just lead me to
examples/pylab_examples/show_colormaps.html (which I already found and
deemed to be not helpful).

 Nick, this is a pretty good example:
 
 http://matplotlib.sourceforge.net/examples/api/colorbar_only.html

If I understand correctly, this explains how to create a discrete
colormap, which isn't quite what I want. But with the two links I can
figure it out the rest, thanks to both of you!


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users