Re: [Matplotlib-users] Fwd: Re: Colobar and change axis x and y labels

2012-02-16 Thread Jerzy Karczmarczuk
Pythphys, would it be too demanding to ask you to sign your messages 
with a human name?...
Danke.

You ask:

 - changing to an image grey scale only needs ... what?
plt.set_cmap(plt.cm.gray)

in the context of your current figure. Or, use cmap=... in your imshow.
Please, look up colormap in the documentation.

 - I need to do a 'plane fit' of the image. Does matplotlib
 have some routine for this? Or shall I use other math libs?

I am not a guru of matplotlib, but this is a visualisation package, not 
a data processing one. Scipy (numpy) have some interpolation procedures, 
polyfit, etc. but I don't remember without digging the docs (which you 
might do as well) whether multidimensional fitting is there.

Anyway, why not use your head? This is a standard student exercise.

You need to fit:   zf = ax + by + c, having z =f(x,y) in your image, am 
I right? If not, forget the rest.

Use the linear regression, find the zero of the gradient wrt (a,b,c) of

SUM[(ax +by +c - z)^2]

and that's all.

The most tragic part of the exercise is the necessity of solving a 
linear equation set in 3 variables...

Jerzy Karczmarczuk
Caen, France


--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] pip install -U matplotlib gives me 1.0.1?

2012-02-16 Thread Jacob Biesinger
Hi!

I currently have matplotlib 1.0.1 installed and would like to upgrade to
1.1.0 but pip is trying to install 1.0.1...

$ pip install -U matplotlib
Downloading/unpacking matplotlib
  Downloading matplotlib-1.0.1.tar.gz (13.3Mb): 516Kb downloaded


Same story when specifying the matplotlib version via a requirements file:

$ cat requirements.txt
matplotlib==1.1.0
$ pip install -r requirements.txt
Downloading/unpacking matplotlib==1.1.0 (from -r requirements.txt (line 1))
  Could not find a version that satisfies the requirement matplotlib==1.1.0
(from -r requirements.txt (line 1)) (from versions: )
No distributions matching the version for matplotlib==1.1.0 (from
-r requirements.txt (line 1))

On PYPI, there is no tarball for 1.1.0
http://pypi.python.org/pypi/matplotlib/1.1.0 but there is for 1.0.1
http://pypi.python.org/pypi/matplotlib/1.0.1 Perhaps someone just forgot to
upload a source tarball?

Thanks for the help!
--
Jake Biesinger
Graduate Student
Xie Lab, UC Irvine
--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] svg in plot

2012-02-16 Thread William Hoburg
Hi everybody,
Is there a way to import a svg-image into a plot?
I know that there are some possibilities to import png 
(http://matplotlib.sourceforge.net/examples/pylab_examples/demo_annotation_box.html)
 or eps (which is then rastered).
But till now I didn't find any way to import/embed a real vector graphic which 
is still a vector when I save the figure again as pdf or svg.
Thanks in advance,
HoWil
-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] svg in plot

2012-02-16 Thread Benjamin Root
On Thu, Feb 16, 2012 at 1:53 PM, Jeffrey Blackburne 
jblackbu...@alum.mit.edu wrote:

 Hi William,

 I am fairly certain that matplotlib does not have the capability to
 do what you are looking for. (If I am wrong, I'm sure someone will
 correct me.)

 You may have better luck using something like Scribus or Inkscape.

 Best,
 Jeff


William,

This is correct.  Matplotlib currently has no import feature available.
Along these lines has been several requests for an ability to import Matlab
.fig files as well.  I believe the official position is that matplotlib is
primarily an exporter library, not an importer library.  The exception to
this rule appears to be imread()...

There is absolutely no reason why a module could not be made for this,
given that everything in matplotlib is assumed to be vector-based.  You
just need a library that can load up the data in the SVG file into
information that is sensibly organized.  Then you run through that data,
producing the relevant artists and collections, adding them to the axes
object.

Maybe pySVG might be a good start?

Cheers!
Ben Root
--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] svg in plot

2012-02-16 Thread Jerzy Karczmarczuk
William Hoburg:
 Is there a way to import a svg-image into a plot?
 I know that there are some possibilities to import png 
 (http://matplotlib.sourceforge.net/examples/pylab_examples/demo_annotation_box.html)
  or eps (which is then rastered).
 But till now I didn't find any way to import/embed a real vector graphic 
 which is still a vector when I save the figure again as pdf or svg.
SVG is a text file, a quite complicated XML. In order to put it into a 
canvas you have to parse it, and to transform all the DEFs, the 
primitives and attributes into plotting commands. Such package as 
matplotlib lives in anther galaxy. It took a lot of time to implement 
SVG in Mozilla or Chrome...

Jerzy Karczmarczuk


--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] svg in plot

2012-02-16 Thread Jerzy Karczmarczuk
I forgot to add something...

Benjamin Root :
 There is absolutely no reason why a module could not be made for this, 
 given that everything in matplotlib is assumed to be vector-based.  
 You just need a library that can load up the data in the SVG file into 
 information that is sensibly organized.
In principle a decent parser can be added to Matplotlib. But...

SVG is NOT entirely a vector drawing program!!

1. You have gradients, clipping paths, patterns, and filtering, which 
interpolates between vector and raster data. You will not implement 
easily as an artist the blur, displacement maps, or morphologic filters

2. SMIL style animation needs a specific engine, this will not easily 
work on a back-end independent framework.

==

Usually I hate people who discourage others, or say that something 
cannot be done. But here, such a module would take too long to 
implement, and the gain seems not adequate. I would be VERY HAPPY, if I 
am wrong.

Jerzy K.


--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] svg in plot

2012-02-16 Thread Benjamin Root
On Thu, Feb 16, 2012 at 2:41 PM, Jerzy Karczmarczuk 
jerzy.karczmarc...@unicaen.fr wrote:

 I forgot to add something...

 Benjamin Root :
  There is absolutely no reason why a module could not be made for this,
  given that everything in matplotlib is assumed to be vector-based.
  You just need a library that can load up the data in the SVG file into
  information that is sensibly organized.
 In principle a decent parser can be added to Matplotlib. But...

 SVG is NOT entirely a vector drawing program!!

 1. You have gradients, clipping paths, patterns, and filtering, which
 interpolates between vector and raster data. You will not implement
 easily as an artist the blur, displacement maps, or morphologic filters


matplotlib does have AGG filters, which are very powerful.  I do concede
that not everything in the SVG spec can be done in matplotlib, but you
would be surprised what can be done.


 2. SMIL style animation needs a specific engine, this will not easily
 work on a back-end independent framework.


I believe the context of the question isn't for animations (although we do
have a backend-independent framework for them, too), but for static SVGs.
I don't think anybody is suggesting a complete solution here.  A module
that can load up many of the common components of an SVG file into a list
of artist and collection objects would be neat, even if it has to throw out
lots of data in an SVG file.

Of course, because it would be impossible to fully implement, such a module
would never be included in matplotlib, but that shouldn't stop someone from
creating a useful basic tool.

Cheers!
Ben Root
--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] _RendererAgg(int(width), int(height), dpi, debug=False): ValueError: width and height must each be below 32768

2012-02-16 Thread Martin Mokrejs
Hi Benjamin,
  thank you for you explanation. My comment is below in the text:

Benjamin Root wrote:
 
 
 On Tue, Feb 14, 2012 at 4:43 PM, Martin Mokrejs mmokr...@fold.natur.cuni.cz 
 mailto:mmokr...@fold.natur.cuni.cz wrote:
 
 Ah, this seems to be the issue that my figsize was growing all the time 
 so it
 went over the maximum limits.
 
 I thought this is valid:
 DefaultSize = F.get_size_inches()
 print str(DefaultSize)
 blah
 F.set_size_inches(DefaultSize)
 
 See http://matplotlib.sourceforge.net/api/figure_api.html
 
 quote
 set_size_inches(*args, **kwargs)
 
set_size_inches(w,h, forward=False)
 
Set the figure size in inches
 
Usage:
 
fig.set_size_inches(w,h)  # OR
fig.set_size_inches((w,h) )
 
optional kwarg forward=True will cause the canvas size to be 
 automatically updated; eg you can resize the figure window from the shell
 
ACCEPTS: a w,h tuple with w,h in inches
 /quote
 
 Nope, it does not work. The print call gives me: [ 8.  6.]. So, this is 
 not a tuple?
 Or python-2.7 issue how is it printed ... I fear? ;-)
 Anyway, doing
 
 F.set_size_inches(11.2, 15)
 
 works for me.
 
 Martin
 
 
 I am a little bit confused by your code example.  You get the figure size and 
 print it, and *then* you set it with the exact same values, and you are 
 surprised that it came out as [8. 6.]?  Note that the figure size is stored 
 internally as a numpy array, so when you do print str(DefaultSize), you 
 will get the string representation of the numpy array.  You can still pass in 
 a tuple, list, or two separate elements.  Try this code:

No, in my experience it did NOT work. I suspect F.set_size_inches() either did 
not like the input tuple or something else. Now. after reading your 
clarification, are you sure it can input the numpy array as well? What I also 
tried was to re-set the figsize to original values.

Ouch, I use pylab not matplotlib directly. :(

$ python
Python 2.7.2 (default, Feb  7 2012, 19:33:08) 
[GCC 4.5.3] on linux2
Type help, copyright, credits or license for more information.
 import pylab
 F = pylab.gcf()
 print F.get_size_inches()
[ 8.  6.]
 DefaultSize = F.get_size_inches()
 print DefaultSize
[ 8.  6.]
 F.set_size_inches(10, 10)
 print F.get_size_inches()
[ 10.  10.]
 F.set_size_inches(DefaultSize[0], DefaultSize[1])
 print F.get_size_inches()
[ 10.  10.]
 

Why in the above example I cannot return back to figsize [ 8.  6.] ?

 
 import matplotlib.pyplot as plt
 fig = plt.figure()
 print fig.get_size_inches()
 fig.set_size_inches(11.2, 15.0)
 print fig.get_size_inches()
 fig.set_size_inches((4.0, 7.2))
 print fig.get_size_inches()
 fig.set_size_inches([9.3, 11.1])
 print fig.get_size_inches()
 
 
 You should see:
 
 [ 8.  6.]
 [ 11.2  15. ]
 [ 4.   7.2]
 [  9.2  11.1]

Yes, this works.

 
 Everything works as expected.  There is nothing special about python 2.7 in 
 this regard.  Let us know if you are still having problems updating your 
 figures and include a stand-alone example showing how the figure size is not 
 being updated.

What does the internal numpy array representation bring good to the figsize? ;-)
Why don't you use a simple list/tuple? I am sure you know what you're doing,
am just curious. Especially if slicing behaves differently compared to 
list/tuple
and the .__str__() also gives in my eyes weird output. Sure, matter of taste. ;)

Thanks,
Martin

--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Selecting a color from a given color map.

2012-02-16 Thread Daniel Welling
Greetings.

I have a series of lines that I would like to plot on the same axis,
but I would like to set the color of each such that the range of
colors used progresses through a given color map (e.g. the default Jet
map.)  For example, if I have 7 lines, the first would use the first
most color from the Jet color map (blue.)  The next line would use the
color that is 1/7 the way up the map, e.g. green or so.  This would
continue until the last line was red.

How would I go about doing this (that is, loading a color map and
pulling a specific color from it that could be handed to plot as an
rgba tuple)?

Thanks!
-dw

--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Selecting a color from a given color map.

2012-02-16 Thread Tony Yu
On Thu, Feb 16, 2012 at 4:14 PM, Daniel Welling dantwell...@gmail.comwrote:

 Greetings.

 I have a series of lines that I would like to plot on the same axis,
 but I would like to set the color of each such that the range of
 colors used progresses through a given color map (e.g. the default Jet
 map.)  For example, if I have 7 lines, the first would use the first
 most color from the Jet color map (blue.)  The next line would use the
 color that is 1/7 the way up the map, e.g. green or so.  This would
 continue until the last line was red.

 How would I go about doing this (that is, loading a color map and
 pulling a specific color from it that could be handed to plot as an
 rgba tuple)?

 Thanks!
 -dw


Hi Daniel,

You can just pass values to a colormap. If those values are evenly spaced
between 0 and 1, you'll get the result you desire. Example:

#~

import numpy as np
import matplotlib.pyplot as plt

n_lines = 10
x = np.linspace(0, 10)

phase_shift = np.linspace(0, np.pi, n_lines)
color_idx = np.linspace(0, 1, n_lines)
for i, shift in zip(color_idx, phase_shift):
plt.plot(x, np.sin(x - shift), color=plt.cm.jet(i))

plt.show()

#~

Coincidentally, this past weekend, I started wrapping up random code like
this into a utility package. See `cycle_cmap` in this package:
https://github.com/tonysyu/mpltools/blob/master/mpltools/color.py. The
package is still in the early stages, and function names could easily
change, so use with caution.

Best,
-Tony
--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] _RendererAgg(int(width), int(height), dpi, debug=False): ValueError: width and height must each be below 32768

2012-02-16 Thread Benjamin Root
On Thu, Feb 16, 2012 at 3:09 PM, Martin Mokrejs mmokr...@fold.natur.cuni.cz
 wrote:

 Hi Benjamin,
  thank you for you explanation. My comment is below in the text:

 Benjamin Root wrote:
 
 
  On Tue, Feb 14, 2012 at 4:43 PM, Martin Mokrejs 
 mmokr...@fold.natur.cuni.cz mailto:mmokr...@fold.natur.cuni.cz wrote:
 
  Ah, this seems to be the issue that my figsize was growing all the
 time so it
  went over the maximum limits.
 
  I thought this is valid:
  DefaultSize = F.get_size_inches()
  print str(DefaultSize)
  blah
  F.set_size_inches(DefaultSize)
 
  See http://matplotlib.sourceforge.net/api/figure_api.html
 
  quote
  set_size_inches(*args, **kwargs)
 
 set_size_inches(w,h, forward=False)
 
 Set the figure size in inches
 
 Usage:
 
 fig.set_size_inches(w,h)  # OR
 fig.set_size_inches((w,h) )
 
 optional kwarg forward=True will cause the canvas size to be
 automatically updated; eg you can resize the figure window from the shell
 
 ACCEPTS: a w,h tuple with w,h in inches
  /quote
 
  Nope, it does not work. The print call gives me: [ 8.  6.]. So, this
 is not a tuple?
  Or python-2.7 issue how is it printed ... I fear? ;-)
  Anyway, doing
 
  F.set_size_inches(11.2, 15)
 
  works for me.
 
  Martin
 
 
  I am a little bit confused by your code example.  You get the figure
 size and print it, and *then* you set it with the exact same values, and
 you are surprised that it came out as [8. 6.]?  Note that the figure size
 is stored internally as a numpy array, so when you do print
 str(DefaultSize), you will get the string representation of the numpy
 array.  You can still pass in a tuple, list, or two separate elements.  Try
 this code:

 No, in my experience it did NOT work. I suspect F.set_size_inches() either
 did not like the input tuple or something else. Now. after reading your
 clarification, are you sure it can input the numpy array as well? What I
 also tried was to re-set the figsize to original values.


Yes, it can.  I found the source of the problem, see further down.


 Ouch, I use pylab not matplotlib directly. :(


Doesn't matter.


 $ python
 Python 2.7.2 (default, Feb  7 2012, 19:33:08)
 [GCC 4.5.3] on linux2
 Type help, copyright, credits or license for more information.
  import pylab
  F = pylab.gcf()
  print F.get_size_inches()
 [ 8.  6.]
  DefaultSize = F.get_size_inches()
  print DefaultSize
 [ 8.  6.]
  F.set_size_inches(10, 10)
  print F.get_size_inches()
 [ 10.  10.]
  F.set_size_inches(DefaultSize[0], DefaultSize[1])
  print F.get_size_inches()
 [ 10.  10.]
 


The bug here is assuming that DefaultSize still contained the values you
printed earlier.  This is subtle (and I missed it before), but what you are
getting back from F.get_size_inches() is a view of the internal numpy
array.  When you set the new size, the internal array was updated, not
replaced.  This is much in the same vein as Python mutables, but taken a
bit further than you are probably used to.  Because the internal array was
updated, the view (stored in DefaultSize) showed the new data as well.  So,
when you tried to set (what you thought was still) the original size, it
was merely setting the current values back to itself.  Therefore, no change.

So, to force DefaultSize to be immutable, just cast it as a tuple:

 DefaultSize = tuple(F.get_size_inches())



 Why in the above example I cannot return back to figsize [ 8.  6.] ?

 
  import matplotlib.pyplot as plt
  fig = plt.figure()
  print fig.get_size_inches()
  fig.set_size_inches(11.2, 15.0)
  print fig.get_size_inches()
  fig.set_size_inches((4.0, 7.2))
  print fig.get_size_inches()
  fig.set_size_inches([9.3, 11.1])
  print fig.get_size_inches()
 
 
  You should see:
 
  [ 8.  6.]
  [ 11.2  15. ]
  [ 4.   7.2]
  [  9.2  11.1]

 Yes, this works.

 
  Everything works as expected.  There is nothing special about python 2.7
 in this regard.  Let us know if you are still having problems updating your
 figures and include a stand-alone example showing how the figure size is
 not being updated.

 What does the internal numpy array representation bring good to the
 figsize? ;-)
 Why don't you use a simple list/tuple? I am sure you know what you're
 doing,
 am just curious. Especially if slicing behaves differently compared to
 list/tuple
 and the .__str__() also gives in my eyes weird output. Sure, matter of
 taste. ;)


We use numpy arrays internally for several reasons.  Primarially is that we
have to do mathematical operations with this information.  list/tuple do
not lend itself to that (which is why numpy exists in the first place).
numpy arrays also enforce type checking (so you can't put a string for a
size value, or anything else that doesn't make sense).  Another reason is
that the slicing is significantly more advanced than for list/tuples.
Internally, there is a 2x2 array.  I can slice in either dimension very
easily, while 

Re: [Matplotlib-users] _RendererAgg(int(width), int(height), dpi, debug=False): ValueError: width and height must each be below 32768

2012-02-16 Thread Martin Mokrejs
Hi Ben,
  glad you found the answer. Once again, does F.get_size_inches() have to 
return to
the user the numpy array? Why not a list or tuple? I don't mind matplotlib 
internal
stuff. ;-)

In an answer to your proposed workaround

 DefaultSize = tuple(F.get_size_inches())

let me comment that (I think) I tried also
 
DefaultSize = F.get_size_inches()[:]

but that also did not work for me. And was similarly think of the copy module 
haven't
bothered to try that. ;-)


  Yes, please document this at least if you really cannot return a simple list 
or tuple.
Thanks,
Martin

Benjamin Root wrote:
 
 
 On Thu, Feb 16, 2012 at 3:09 PM, Martin Mokrejs mmokr...@fold.natur.cuni.cz 
 mailto:mmokr...@fold.natur.cuni.cz wrote:
 
 Hi Benjamin,
  thank you for you explanation. My comment is below in the text:
 
 Benjamin Root wrote:
 
 
  On Tue, Feb 14, 2012 at 4:43 PM, Martin Mokrejs 
 mmokr...@fold.natur.cuni.cz mailto:mmokr...@fold.natur.cuni.cz 
 mailto:mmokr...@fold.natur.cuni.cz mailto:mmokr...@fold.natur.cuni.cz 
 wrote:
 
  Ah, this seems to be the issue that my figsize was growing all the 
 time so it
  went over the maximum limits.
 
  I thought this is valid:
  DefaultSize = F.get_size_inches()
  print str(DefaultSize)
  blah
  F.set_size_inches(DefaultSize)
 
  See http://matplotlib.sourceforge.net/api/figure_api.html
 
  quote
  set_size_inches(*args, **kwargs)
 
 set_size_inches(w,h, forward=False)
 
 Set the figure size in inches
 
 Usage:
 
 fig.set_size_inches(w,h)  # OR
 fig.set_size_inches((w,h) )
 
 optional kwarg forward=True will cause the canvas size to be 
 automatically updated; eg you can resize the figure window from the shell
 
 ACCEPTS: a w,h tuple with w,h in inches
  /quote
 
  Nope, it does not work. The print call gives me: [ 8.  6.]. So, 
 this is not a tuple?
  Or python-2.7 issue how is it printed ... I fear? ;-)
  Anyway, doing
 
  F.set_size_inches(11.2, 15)
 
  works for me.
 
  Martin
 
 
  I am a little bit confused by your code example.  You get the figure 
 size and print it, and *then* you set it with the exact same values, and you 
 are surprised that it came out as [8. 6.]?  Note that the figure size is 
 stored internally as a numpy array, so when you do print str(DefaultSize), 
 you will get the string representation of the numpy array.  You can still 
 pass in a tuple, list, or two separate elements.  Try this code:
 
 No, in my experience it did NOT work. I suspect F.set_size_inches() 
 either did not like the input tuple or something else. Now. after reading 
 your clarification, are you sure it can input the numpy array as well? What I 
 also tried was to re-set the figsize to original values.
 
 
 Yes, it can.  I found the source of the problem, see further down.
  
 
 Ouch, I use pylab not matplotlib directly. :(
 
 
 Doesn't matter.
  
 
 $ python
 Python 2.7.2 (default, Feb  7 2012, 19:33:08)
 [GCC 4.5.3] on linux2
 Type help, copyright, credits or license for more information.
  import pylab
  F = pylab.gcf()
  print F.get_size_inches()
 [ 8.  6.]
  DefaultSize = F.get_size_inches()
  print DefaultSize
 [ 8.  6.]
  F.set_size_inches(10, 10)
  print F.get_size_inches()
 [ 10.  10.]
  F.set_size_inches(DefaultSize[0], DefaultSize[1])
  print F.get_size_inches()
 [ 10.  10.]
 
 
 
 The bug here is assuming that DefaultSize still contained the values you 
 printed earlier.  This is subtle (and I missed it before), but what you are 
 getting back from F.get_size_inches() is a view of the internal numpy array.  
 When you set the new size, the internal array was updated, not replaced.  
 This is much in the same vein as Python mutables, but taken a bit further 
 than you are probably used to.  Because the internal array was updated, the 
 view (stored in DefaultSize) showed the new data as well.  So, when you tried 
 to set (what you thought was still) the original size, it was merely setting 
 the current values back to itself.  Therefore, no change.
 
 So, to force DefaultSize to be immutable, just cast it as a tuple:
 
 DefaultSize = tuple(F.get_size_inches())
 
  
 
 Why in the above example I cannot return back to figsize [ 8.  6.] ?
 
 
  import matplotlib.pyplot as plt
  fig = plt.figure()
  print fig.get_size_inches()
  fig.set_size_inches(11.2, 15.0)
  print fig.get_size_inches()
  fig.set_size_inches((4.0, 7.2))
  print fig.get_size_inches()
  fig.set_size_inches([9.3, 11.1])
  print fig.get_size_inches()
 
 
  You should see:
 
  [ 8.  6.]
  [ 11.2  15. ]
  [ 4.   7.2]
  [  9.2  11.1]
 
 Yes, 

Re: [Matplotlib-users] (no subject)

2012-02-16 Thread de...@verizon.net
..Gain Your Freedom, Manage Your Own Business  
http://gay68.sexerapide.com/job.link.php?ispage=87dy6

--
Sent using Verizon.net Mobile
--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] svg in plot

2012-02-16 Thread Jerzy Karczmarczuk
Benjamin Root :
 it would be impossible to fully implement, such a module would never 
 be included in matplotlib, but that shouldn't stop someone from 
 creating a useful basic tool.
Yes. Thank you Ben. I so concentrated on the vector side of the 
original question that I forgot that AGG has a rasterizer and filters, 
and morover Matplotlib can rescale (regenerate) bitmaps when resizing 
the figure!

OK. Since the ActiveState cookbook
http://code.activestate.com/recipes/325823-draw-svg-images-in-python/
offers some programme to draw SVGs, and the SVG parsers are doable, 
somebody might start tomorrow.
Great!

Jerzy K.


--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] _RendererAgg(int(width), int(height), dpi, debug=False): ValueError: width and height must each be below 32768

2012-02-16 Thread Benjamin Root
On Thursday, February 16, 2012, Martin Mokrejs wrote:

 Hi Ben,
  glad you found the answer. Once again, does F.get_size_inches() have to
 return to
 the user the numpy array? Why not a list or tuple? I don't mind matplotlib
 internal
 stuff. ;-)


We don't return a list or a tuple because other functions within mpl needs
the numpy array.



 In an answer to your proposed workaround

  DefaultSize = tuple(F.get_size_inches())

 let me comment that (I think) I tried also

 DefaultSize = F.get_size_inches()[:]

 but that also did not work for me. And was similarly think of the copy
 module haven't
 bothered to try that. ;-)


You might want to read up on numpy arrays.  A slice of an array returns a
view.  A slice on a view also returns a view.  If you want a copy, the
array has a copy() method.  I don't know if the copy module would actually
work because it would merely be copying the view (creating a duplicate
view).

Ben Root



  Yes, please document this at least if you really cannot return a simple
 list or tuple.
 Thanks,
 Martin

 Benjamin Root wrote:
 
 
  On Thu, Feb 16, 2012 at 3:09 PM, Martin Mokrejs 
 mmokr...@fold.natur.cuni.cz javascript:; mailto:
 mmokr...@fold.natur.cuni.cz javascript:; wrote:
 
  Hi Benjamin,
   thank you for you explanation. My comment is below in the text:
 
  Benjamin Root wrote:
  
  
   On Tue, Feb 14, 2012 at 4:43 PM, Martin Mokrejs 
 mmokr...@fold.natur.cuni.cz mailto:mmokr...@fold.natur.cuni.cz mailto:
 mmokr...@fold.natur.cuni.cz mailto:mmokr...@fold.natur.cuni.cz wrote:
  
   Ah, this seems to be the issue that my figsize was growing all
 the time so it
   went over the maximum limits.
  
   I thought this is valid:
   DefaultSize = F.get_size_inches()
   print str(DefaultSize)
   blah
   F.set_size_inches(DefaultSize)
  
   See http://matplotlib.sourceforge.net/api/figure_api.html
  
   quote
   set_size_inches(*args, **kwargs)
  
  set_size_inches(w,h, forward=False)
  
  Set the figure size in inches
  
  Usage:
  
  fig.set_size_inches(w,h)  # OR
  fig.set_size_inches((w,h) )
  
  optional kwarg forward=True will cause the canvas size to
 be automatically updated; eg you can resize the figure window from the shell
  
  ACCEPTS: a w,h tuple with w,h in inches
   /quote
  
   Nope, it does not work. The print call gives me: [ 8.  6.].
 So, this is not a tuple?
   Or python-2.7 issue how is it printed ... I fear? ;-)
   Anyway, doing
  
   F.set_size_inches(11.2, 15)
  
   works for me.
  
   Martin
  
  
   I am a little bit confused by your code example.  You get the
 figure size and print it, and *then* you set it with the exact same values,
 and you are surprised that it came out as [8. 6.]?  Note that the figure
 size is stored internally as a numpy array, so when you do print
 str(DefaultSize), you will get the string representation of the numpy
 array.  You can still pass in a tuple, list, or two separate elements.  Try
 this code:
 
  No, in my experience it did NOT work. I suspect F.set_size_inches()
 either did not like the input tuple or something else. Now. after reading
 your clarification, are you sure it can input the numpy array as well? What
 I also tried was to re-set the figsize to original values.
 
 
  Yes, it can.  I found the source of the problem, see further down.
 
 
  Ouch, I use pylab not matplotlib directly. :(
 
 
  Doesn't matter.
 
 
  $ python
  Python 2.7.2 (default, Feb  7 2012, 19:33:08)
  [GCC 4.5.3] on linux2
  Type help, copyright, credits or license for more
 information.
   import pylab
   F = pylab.gcf()
   print F.get_size_inches()
  [ 8.  6.]
   DefaultSize = F.get_size_inches()
   print DefaultSize
  [ 8.  6.]
   F.set_size_inches(10, 10)
   print F.get_size_inches()
  [ 10.  10.]
  
--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users