Re: [matplotlib-devel] What would you like to see in a book about Matplotlib?

2009-02-01 Thread Sandro Tosi
Hi Chris,
thanks for your reply, helpful as usual :)

On Fri, Jan 30, 2009 at 18:59, Chris Walker
 wrote:
>   Firstly, good luck with the book.

cheers :)

> The sort of book I'd buy would explain how to use the combination of
> matplotlib/ipython/scipy/numpy to analyse data.

Sadly, that would not the book I'll write :( The editor wanted to
target another audience for the book: experienced python developers,
with no knowledge of matplotlib; so an introductionary book, that will
show even how to integrate mpl on GTK/WX application and on the web.

I pushed to have something about science, and a chapter will be about
that, but I need your (all) inputs, because my science days are long
back in the past ;)

>> - what are the (basic) things that, when you were beginning to use
>> matplotlib, you wanted to see grouped up but couldn't find?
>> - what would you like to see in a book about matplotlib?
>
> Start off by reading data from a file, plotting it and fitting a
> function to that data.

That sounds something that could land in the "science" chapter.

> Plotting with related scales
> 
>
> Sometimes it is useful to plot related scales on x1 and x2 axes. I've
> come across this several times in different contexts. In its simplest
> form, there is a linear relationship between the axes. In a mechanical test, 
> you might want extension on the x1 axis and strain on the x2 axis (for 
> example).
>
> Sometimes there is not a linear relationship. For example you might
> want to plot frequency (or photon energy) on x1 and wavelength on x2.
>
> An even more complex example is a Hall-Petch plot:
>
> (Yield Stress) = k/sqrt(Grain Size)
>
> So plotting 1/Sqrt(Grain Size) on the X1 axis gives a linear
> plot, but it would be useful to plot the grain size on the X2 scale.

Err, I think I lost you ;)

What you want is 2 plots on the same figure? so not 2 Ys for the same
X (let's say X is time, and Y1 is stock price variation, and Y2 is the
percentage change), you want X1-Y1 (let's say on the bottom-left) and
X2-Y2 (on the upper-right): did I get you?

> ipython and emacs
> -
>
> Suppose I want to write a script to analyse some data (perhaps I want
> a record of what I've done, or perhaps I'd like to perform the same
> analysis on several data sets). I'd probably do so in emacs - but it
> is useful to do some experimentation in ipython - tab completion is
> particularly useful. I feel there must be a good way to do my
> experimentation in ipython and save the important bits in emacs - but
> I've not sat down and worked out an efficient way of doing this.

I think the preferred way to do so it using ipython, and for now I
plan only to show it on the book.

> Data aqcuisition and experimental control:
> -
>
> Writing a simple application to acquire data - ideally from multiple
> sources and plot the data as it is acquired. In my case I wanted to
> combine mechanical with electrical tests. A couple of interesting
> articles by G Varoquaux are listed at
> http://wiki.debian.org/DebianScience/DataAcquisition
>
> This is perhaps beyond the scope of the book, but it has come up on
> the mailing lists a couple of times. The ideal application would have
> a gui for simple use, but a command line (probably ipython) for more
> more complex use - perhaps performing a series of tests under
> different conditions.

I thought about an example for this already! :) I thought to develop a
sample application for GTK/WX that display some system value (like cpu
usage or so, in this way everyone can run the example) plotting the
information as it comes (for 30 secs, for example).

> Some discussion of plotting non gridded 2d data should also be in
> there.

for example?

>> Your suggestions are really appreciated :) And wish me good luck!
>
> I don't think it is the thrust of your book, but another book I was
> looking for is "A cookbook of Numerical simulations of classic
> physics/engineering problems". For use by physicists/engineers who
> don't want to rewrite things from scratch.

As said, even if my degree is in linear algebra, my science days are
gone, so it won't be in the book, if not for that chapter about
science and mpl.

> Good luck.

Cheers,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi

--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] A small patch for sphinxext tools

2009-02-01 Thread Fernando Perez
Hi all,

in various places I've been using the mpl sphinxext tools, so I
figured I'd best send you a few small updates I've made to them before
they bitrot too much.  Most of the changes are just cleanup and
documentation, though there is a functional fix in
inheritance_diagram, which was just not working for us in nipy.
There's a comment indicating the change,  I hope it makes sense.

I made the patch against svn trunk, though I can't quite test because
I'm getting this:

maqroll[doc]> ./make.py html
Traceback (most recent call last):
  File "./make.py", line 98, in 
func()
  File "./make.py", line 31, in html
shutil.copy('../lib/matplotlib/mpl-data/matplotlibrc',
'_static/matplotlibrc')
  File "/usr/lib/python2.5/shutil.py", line 85, in copy
copyfile(src, dst)
  File "/usr/lib/python2.5/shutil.py", line 51, in copyfile
fsrc = open(src, 'rb')
IOError: [Errno 2] No such file or directory:
'../lib/matplotlib/mpl-data/matplotlibrc'


I'm a bit surprised to see this problem, since I imagine you guys
build frequently.  But my svn is indeed up to date and that file is
just not there.  I'm not sure which way you want the fix to go, so
I'll leave that decision to you guys.

Cheers,

f
Index: inheritance_diagram.py
===
--- inheritance_diagram.py	(revision 6861)
+++ inheritance_diagram.py	(working copy)
@@ -42,6 +42,17 @@
 from docutils.parsers.rst import directives
 from sphinx.roles import xfileref_role
 
+def my_import(name):
+"""Module importer - taken from the python documentation.
+
+This function allows importing names with dots in them."""
+
+mod = __import__(name)
+components = name.split('.')
+for comp in components[1:]:
+mod = getattr(mod, comp)
+return mod
+
 class DotException(Exception):
 pass
 
@@ -84,6 +95,13 @@
 path = base
 try:
 module = __import__(path, None, None, [])
+# We must do an import of the fully qualified name.  Otherwise if a
+# subpackage 'a.b' is requested where 'import a' does NOT provide
+# 'a.b' automatically, then 'a.b' will not be found below.  This
+# second call will force the equivalent of 'import a.b' to happen
+# after the top-level import above.
+my_import(fullname)
+
 except ImportError:
 raise ValueError(
 "Could not import class or module '%s' specified for inheritance diagram" % name)
Index: ipython_console_highlighting.py
===
--- ipython_console_highlighting.py	(revision 6861)
+++ ipython_console_highlighting.py	(working copy)
@@ -1,18 +1,32 @@
+"""reST directive for syntax-highlighting ipython interactive sessions.
+"""
+
+#-
+# Needed modules
+
+# Standard library
+import re
+
+# Third party
 from pygments.lexer import Lexer, do_insertions
-from pygments.lexers.agile import PythonConsoleLexer, PythonLexer, \
-PythonTracebackLexer
+from pygments.lexers.agile import (PythonConsoleLexer, PythonLexer, 
+   PythonTracebackLexer)
 from pygments.token import Comment, Generic
+
 from sphinx import highlighting
-import re
 
+
+#-
+# Global constants
 line_re = re.compile('.*?\n')
 
+#-
+# Code begins - classes and functions
+
 class IPythonConsoleLexer(Lexer):
 """
 For IPython console output or doctests, such as:
 
-Tracebacks are not currently supported.
-
 .. sourcecode:: ipython
 
   In [1]: a = 'foo'
@@ -24,7 +38,14 @@
   foo
 
   In [4]: 1 / 0
+
+Notes:
+
+  - Tracebacks are not currently supported.
+
+  - It assumes the default IPython prompts, not customized ones.
 """
+
 name = 'IPython console session'
 aliases = ['ipython']
 mimetypes = ['text/x-ipython-console']
@@ -72,4 +93,6 @@
   pylexer.get_tokens_unprocessed(curcode)):
 yield item
 
+#-
+# Register the extension as a valid pygments lexer
 highlighting.lexers['ipython'] = IPythonConsoleLexer()
Index: mathmpl.py
===
--- mathmpl.py	(revision 6861)
+++ mathmpl.py	(working copy)
@@ -1,3 +1,25 @@
+"""matplotlib-based directive for math rendering in reST using sphinx.
+
+To use this extension, add ``mathmpl`` to the list of extensions in
+:file:`conf.py`.
+
+Note:
+
+Current SVN versions of Sphinx now include built-in support for math.
+There are two flavors:
+
+  - pngmath: uses dvipng to render the equation
+
+  - jsmath: renders the math in the browser using Javascript
+
+To 

Re: [matplotlib-devel] A small patch for sphinxext tools

2009-02-01 Thread Jae-Joon Lee
> I'm a bit surprised to see this problem, since I imagine you guys
> build frequently.  But my svn is indeed up to date and that file is
> just not there.  I'm not sure which way you want the fix to go, so
> I'll leave that decision to you guys.

I believe mpl-data/matplotlibrc is not version-controled, but created
when you run setup.py.
Maybe you're trying to build the documentation from a new svn checkout
but didn't build the library?

Regards,

-JJ

--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] A small patch for sphinxext tools

2009-02-01 Thread Fernando Perez
On Sun, Feb 1, 2009 at 9:22 PM, Jae-Joon Lee  wrote:
>> I'm a bit surprised to see this problem, since I imagine you guys
>> build frequently.  But my svn is indeed up to date and that file is
>> just not there.  I'm not sure which way you want the fix to go, so
>> I'll leave that decision to you guys.
>
> I believe mpl-data/matplotlibrc is not version-controled, but created
> when you run setup.py.
> Maybe you're trying to build the documentation from a new svn checkout
> but didn't build the library?

Aha, that's it, thanks.  I'd run svn-clean just before to make sure I
had a clean setup before making the patch, so my build had just been
nuked.

Nothing to worry then, I just did a rebuild and it all seems to work.
So at least the patch doesn't completely crash the doc build :)

Cheers,

f

--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel