## Matplotlib For Python Developers 119

Craig Maloney writes

tester data*"Ever since there was a collection of numbers, it seems that invariably someone will want a graph of those numbers. There are literally hundreds of different styles of graphs, and almost as many programs and tools to make those graphs. Matplotlib, a library and toolkit for the Python language, provides an easy and effective way to make some impressive graphics with little more than a smattering of Python.*Read below for the rest of Craig's review.*Matplotlib for Python Developers*is equally impressive at distilling the core set of features of Matplotlib in a way that shows the reader how to get the most out the Matplotlib toolkit."Matplotlib for Python Developers | |

author | Sandro Tosi |

pages | 291 |

publisher | Packt Publishing |

rating | 9/10 |

reviewer | Craig Maloney |

ISBN | 978-1-847197-90-0 |

summary | A comprehensive overview of the powerful Matplotlib Python library |

*Matplotlib for Python Developers*begins with the customary introduction to the Matplotlib library. It includes where to download Matplotlib, as well as brief installation instructions for both Linux, Macintosh, and Windows platforms. The book then quickly moves to the next chapter, where the basic library functions are presented, via the interactive iPython shell. Each section of the chapter introduces a new part of the graph, with items like titles, grid lines, and labels being explained clearly and concisely. Also briefly presented are other useful libraries like numpy, as well as the various back-ends that Matplotlib supports. Chapter 3 continues the even pace, presenting more plot styles, and plot types, including polar graphs. These two chapters cover the fundamentals of Matplotlib very well, with each step clearly marked by what the graph should look like once completed.

The next chapter introduces more advanced plotting concepts that Matplotlib is capable of handling. The chapter begins with the three ways that Matplotlib may be used (The pyplot module, pylab, and the Object Oriented interface). From there, the book delves into subplots, multiple figures, additional axes, logarithmic axes, date plotting, contour plots, and image plots. Also included are sections on using LaTeX and TeX with Matplotlib, both for exporting graphs, as well as using TeX inside plots via Mathtext. By the end of the chapter, I felt very comfortable with the environment and the capabilities of Matplotlib, both as an interactive environment, and as a module for my own programs.

The next four chapters cover integrating Matplotlib with GTK+, QT4, wxWidgets, and web-based environments. The chapters for GTK+, QT4, and wxWidgets each begin by presenting a basic overview of the toolkit, and why one might want to use that particular toolkit. Next, the book shows how to embed a Matplotlib figure in a window, both with static and real-time data input. The book then shows how to use the toolkit's builder with Matplotlib (Glade for GTK+, QT Designer for QT4, and wxGlade for wxWidgets. The chapter on web development veers slightly from this format by showing several examples of using CGI and mod_python with Matplotlib before showing how to use Matplotlib with Django and Pylons.

The last chapter pulls together some "real world" examples together for the grand finale. The examples clearly show how Matplotlib would work for such plotting Apache web logs, fitting curves, and plotting geographic data. The geographic data plotting uses an additional module called basemap, which allows for plotting precisely on a map. This example floored me with the amount of power that Matplotlib possesses.

Overall, I found this book to be informative, without a lot of fluff. The organization of the book sometimes dipped into a chaotic presentation of "oh, look at this", but overall the author kept a very even pace, with clearly defined goals and clean resolution of those goals.

*Matplotlib for Python Developers*is definitely a book that I would pick up to refresh my memory for using Matplotlib. The asking price is a bit steep for book that is just shy of 300 pages, but overall I highly recommend it for anyone looking to get started with this exceptional library. I'd also recommend it for anyone looking for alternatives to some of the other plotting packages available. Matplotlib is quite powerful, and

*Matplotlib for Python Developers*makes this power very accessible.

You can purchase

*Matplotlib for Python Developers*from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

## Why does everything need 250+ pages? (Score:3, Insightful)

This is something that ought to be one chapter in a Python book, not another boat-anchor of a standalone book.

## Re: (Score:1)

Because you don't become a matplotlib master by doing 12,000 things, you become a matplotlib master by doing 4 things 12,000 times.

Or something. Hell man, I agree with you.

## Re: (Score:1)

Have you actually used matplotlib? Like with any plotting package (or at least all the ones I've ever used) there are some subtle but important details where a 20 page handout just wouldn't do. You don't like the book, don't buy the f'ing thing.

- kg

## Re: (Score:3, Informative)

Matplotlib which I use a lot, has really sucky documentation so this 250 pages would amount to basically all the documents. Additionally, you have to realize that matplot lib is not one coherent entity. it's a mish mash of many many things in numberical analysis much of it having to manage legacy cases and pertending to ape matlab syntax. So there's lots of special cases to cover.

On the otherhand I really have ot wonder sometimes if matplotlib is a dead project. All of the standard distro's have 3D pl

## Re: (Score:2)

If your chosen python packager doesn't do an adequate job of including matplotlib then install it yourself. It's a double click (or equivalent) on the major platforms. Certainly not dead.

## Re: (Score:2)

If your chosen python packager doesn't do an adequate job of including matplotlib then install it yourself. It's a double click (or equivalent) on the major platforms. Certainly not dead.

ha! have you ever tried to install the 3d packages or any of the advanced math stuff. it's most definitely not easy. it's dependency hell. hence the package manager is the only way that seems to work. It is true you can find a few binary distros out there. but again everything I said is true: the 3D depends on unmaintained packages and you can't find them in all distros. As a result it makes distributing code to other scientist a problem.

## Re: (Score:3, Informative)

Yes, I have. The math stuff is just fine. The hardest part is usually installing LaTeX. The 3D stuff is unmaintained. There was some initial interest in it a few years ago and then it sort of died because there are other, better ways to plot in 3D. Even so, I believe the VTK integration still works reasonably well, and it just requires installing VTK and one other package. You might have a point that the third-party 3D addons to matplotlib are dead, but matplotlib itself certainly isn't.

The best way t

## Re: (Score:2)

The best way to distribute a Python environment is to tar the whole thing up and send it to whomever. An alternative is just to tar up the site-packages directory. For a long time I had a separate, easily accessible site-packages that could be packaged and distributed to everyone in the lab on a regular basis. On OS X you can even make a pretty double click installer in about five minutes.

I'd love some advice on this if you would care to share. I'm always afraid that when I do an install it will end up putting something into a tree I'll miss in a tar ball. The other problem is that when I'm using a distro like fink, I'm not sure how to make sure I include everything I need to send python in a self contained way without sending all of fink. Tips wold be apreciated. I'm not a python nuts and bolts genius, more of an end user.

## Re: (Score:2)

Since you mentioned Fink I'm assuming you're on a Mac?

On any Unix it's a good idea to do a Python install in someplace other than the system Python location. Particularly on the Mac. Some system scripts are written in Python and it's a good idea not to mess with the Python they depend on.

The standard way to do an install on the Mac is as a framework. If you're building Python from scratch, you use the flag --framework-install. I haven't done that for a while since the binaries available from python.org

## Re: (Score:2)

thanks a lot. that really helped.

## Re: (Score:2)

Happy to help.

## Re: (Score:2)

If you can't think of enough ways to graphically display information to fill a 250 page book, that says more about your lack of imagination than the utility of a plotting library.

## Re: (Score:2)

## *yawn* (Score:2, Funny)

Wake me up when someone writes about Sillyplotadlib for Monty Python developers.

## already reviewed (Score:1)

## Re: (Score:2)

is it my imagination or has this been reviewed on slashdot before?

## Re: (Score:1)

is it my imagination or has this been reviewed on slashdot before?

--

## Re: (Score:1)

## Python for Scientific use (Score:3, Insightful)

It seems that version 3.0 has gotten better for us scientific users. However, I think the programmers out there are now dissatisfied.

## Re: (Score:1)

Why are you anthropomorphizing?

The core Python dev team is probably mostly agnostic towards changes that benefit scientists, especially if there are no costs to programmers, or huge amounts of maintenance.

Another group of people is working hard to make tools for doing science in Python.

Switching over to doing float division by default isn't that huge a change, and it is aimed at beginners, not scientists. If number literals had been converted over to being interpreted as rationals, maybe you'd have an argum

## Re: (Score:3, Insightful)

Why are you anthropomorphizing?Because it's a narrative device that can be used effectively to communicate. You didn't have any trouble understanding that "python" in that context stood for the python development community, did you? You didn't seriously think he was ascribing a human like intelligence to a language specification, did you? That anthropomorphism avoids clutter and actually increases readability, and after all, :P

readability counts.That being said, I have to agree with you. Part of the

## Re: (Score:1)

I asked the anthropomorphism question because it seemed like maybe he was taking the device a little too literally, treating the community as a monolithic block. It was a device of my own.

## Re: (Score:2, Informative)

Yes, I saw that and had similar thoughts. Also they should look at virtual environment [python.org] and look at Interactive python [scipy.org]

## Re: (Score:1)

I've heard quite a few people here on Slashdot talk about how useful Python is as a substitute for MATLAB. Honestly, I don't get it.

MATLAB is a great product, and what it does it does well. But sooner or later you grow out of it, depending on how far you need to push it, and how much previous experience you have with real programming languages. When that day comes, Python is there waiting, and its can be sooo refreshing.

## Re: (Score:2)

I'd also add that when it comes to shipping code to a client, pointing them to a Python download vs. shelling out for a MATLAB license can be a factor as well. I like MATLAB but there's no denying there's a degree of sticker shock with it.

## Re: (Score:3, Informative)

Not even quite sure MATLAB "does what it does well". Its usually a great way to get started, especially if you don't quite know what you are doing. But then I often find myself wondering why I am working around bugs and re-writing functions in a $10k software package. Moved almost everything to python/numpy/scipy/Matplotlib over a year ago and really haven't looked back.

Here's one thing that Matplotlib should not have replicated from MATLAB: insane memory usage.

Please folks, lets get it under control: 1G of

## Re: (Score:2)

In my experience, while Matlab is a great way to get started, the code you produce in Matlab tends to be difficult to port across nicely, even to Python, because Matlab just does stuff in such a unique and honestly, bizarre way. I agree, Matlab doesn't really do anything well in my opinion, hell I am a TA for first year Matlab classes at my uni and I hate every minute of it.

## Re: (Score:2)

## Re: (Score:2, Insightful)

## Re: (Score:3, Informative)

That echoes my experience. I generally prefer Chaco [enthought.com] for plots in Python since it seems to handle large datasets better than matplotlib (although matplotlib seems more functional), but matplotlib is comfortable for MATLAB users. I'm working on a SciPy project with a couple of MATLAB refugees and they love matplotlib.

## Re: (Score:2)

## IDEs for Python (Score:2)

There are some excellent IDEs for Python. They don't "come with" Python because they are big and somewhat platform dependent. Python IDEs that are useful for scientific work include Python(x,y), Sage, reInteract, and DrPython (you can find them on Google).

You're right that Python syntax is not perfectly adapted to scientific use, but I haven't found it to be a big deal. By being based on a general purpose language, however, you get a huge set of libraries that you simply can't get for MATLAB. And maybe

## Re: (Score:3, Insightful)

With the exception of people writing bare-metal assembly for microcontrollers or something, pretty much everyone who sits down to write some code has huge swaths of pre-written stuff loaded for them. The only difference is how much of that happens automatically, by default, and how much you see and do yourself.

If the science types happen to like python for some syntact

## Re: (Score:1)

## Re: (Score:2)

I've heard quite a few people here on Slashdot talk about how useful Python is as a substitute for MATLAB. Honestly, I don't get it.I think there are many programs built on MATLAB which could be as easily and effectively built on Python and associated libraries. I do not see scipy/numpy/ipython/matplotlib as a dropin replacement for the MATLAB interactive environment, because they are different (even if equally capable).

Python is trying to be a language for both hard core programming, and scientific programing.I do not feel like it is trying to be either. I think it is trying to be as suitable as it can for both of those things without compromising elegance.

I don't want to load 20 modules before I can begin coding. I just want to input my algorithm and get a result I expect (not 5/2=2).Since I can trivially make a file "mystartup.py" with import statemen

## Re:Python for Scientific use (Score:4, Insightful)

I just want to input my algorithm and get a result I expect (not 5/2=2).

What result do you expect from 5/2? I expect 2... 5/2 == 2 in C, C++ and FORTRAN (I think... I don't write much FORTRAN code these days...)

Python does an excellent job of making both useful scientific functionality available via scipy and numpy and a wealth of other toolkits, and at the same time allowing us to package stuff up in usable applications. It provides all the real-world applications language facilities that MATLAB, Mathematica, R, etc lack.

I deal with people who "code" in those environments all the time, and they are not my peers: they have fundamentally failed to grasp almost everything important about programming, from design principles to documentation. For someone who knows how to write software--which MATLAB et al "programmers" do not, as a professional understands the term--Python is pretty much ideal for expressing algorithms and wrapping them in useful applications.

## Re: (Score:2, Informative)

What result do you expect from 5/2? I expect 2... 5/2 == 2 in C, C++ and FORTRAN (I think... I don't write much FORTRAN code these days...)

Just watch out in python 3.0, this will change. Because of python's duck-typing, you can never be certain if you were getting an integer or a float, and so it is possible to get different behaviors implicitly. Because python's mantra is "Explicit is better than Implicit", python 3.0 will only do integer (called floored) division when you do '//'.

## Re: (Score:2)

It doesn't matter I'd you grasp basic code design or not, Matlab et al simply don't support that sort I thing, or have support poorly grafted on afterward because they were never designed for real coding. I say this as a scientist who uses everything from assembler to Python and has had the unenviable task of figuring out what someone else's thousand line long matlab programs were doing.

## Re: (Score:1)

## Python is general purpose (Score:2)

Python's dynamic object orientation allows it to be used for a wide range of rapid development in many fields.

I use it for scientific programming. While it does not have as many libraries as matlab or R, it is great because I can call R routines from python plus does things like threading and complex file manipulation, that the others do poorly.

Python is not bad numerically, you just have to be clear about what objects you are using when. If you don't want 5/2=2, then use 5./2.

## Re: (Score:3, Interesting)

Wake me when there is something even close to replace Simulink. Matlab is cool and all, but the real power of the program is Simulink.

## Re: (Score:2)

Depending on your requirements, Scicos might be what you are looking for.

## Re: (Score:2)

Or modelica [wikipedia.org]. I haven't used it, but it looks interesting.

## Re: (Score:2)

Why? Simulink sucks, what on earth would prevent you from doing that stuff in raw Python, or a good micro language? Do you think control systems really need a $10k package to operate? Simulink is great for prototyping, and for engineers who can't program, thats about it I reckon.

## Re:Python for Scientific use (Score:4, Insightful)

I use Python for scientific computing and much, much, much prefer it to MATLAB. Most of what I do does not require sophisticated library routines, and the sophisticated stuff I do need generally either aren't common enough to exist for MATLAB or are quirky enough that I wouldn't trust someone else's library to have the details right. Thus, the typically cited advantages of MATLAB are not there for me. Python provides a much better thought out programming language. It's sometimes a bit less convenient for interactivity, but really I got used to using it (plus matplotlib an numpy) quickly and I have not felt the urge to move back to MATLAB for quite some time. Very occasionally I'll pop in to do a crude curve fit, but not often.

The needs of scientific programming and hard core programming (whatever exactly that means) are not so different. As for not wanting to load modules, um, what? I can think of reasonable complaints about Python, but I don't consider that among them. That reeks of "it's different so I don't like it," which is not a well thought through reason.

## Re: (Score:3, Informative)

## Re:Python for Scientific use (Score:4, Informative)

Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55)

[GCC 4.4.1] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> 5/2 #Diving integers in Python 2.6 gives an integer

2

>>> from __future__ import division

>>> 5/2 #Things work differently in the future

2.5

>>> 5//2 #You can use a double '/' to explicitly force an integer in Python 3

2

## Re: (Score:2)

Has anyone actually worked with Sage? How is it? How / when did you find it superior? Pros/cons?

## Re:Python for Scientific use (Score:4, Informative)

That's exactly the output you should expect for integer division, which is what 5/2 is asking for.On what planet? Just because C works that way, and Python works that way (at least until now), doesn't mean it's the best way, or the most useful way, or that it could never be changed.

That's EXACTLY the point being made here -- people are touting Python as a scientific computing platform, but the result "5/2 == 2" is almost never what you want when doing scientific calculations. So from the standpoint of scientific coding, some features are really not ideal.

## Re: (Score:2)

with remainder 1. That's what Euclid's algorithm gives us.The correct approach should be to represent the output of 5/2 as a pair of integers, but my guess is that for some reason the early language designers felt that an operation taking one interger into a pair of integers wasn't elegant or too much trouble to get right, and so we ended up with the ugliness that is / and its little used cousin %.

## Re: (Score:2)

What the hell are you rambling about? Long numerical calculations do not involve intermediate rounding except in very specific circumstances. Data always have some amount of noise to them -- rounding at inappropriate moments AMPLIFIES the noise. The direction to which a value rounds depends which side of 0.5 the fractional part falls on. If the exact value (which we cannot know precisely) is very close to 0.5 in the fractional part, then whether the value rounds up or rounds down

may depend entirely on the## Re: (Score:2)

2.5000000000000000 is. e.g. 0x4004000000000000 Congratulations, your arithmetic now has 15 more sigfigs than what happened when you used a pencil.What the hell are you talking about? Just because the value in the register, if written out, is 2.5000000000000000, doesn't mean that anybody believes that the value is exact.

What the hell good is math accurate out to 10 places when I only have an 8 bit A2D on an input in the process loop?Because I don't want to accumulate roundoff noise in each fucking calcu

## Care about roundoff? You better know types. (Score:1)

Isn't it fair to say that if you're worried about roundoff noise in repeated calculations, you've passed the point from being just a scientist to a someone who should be concerned with general programming theory and conventions, and hence at least familiar and comfortable with notation that denotes type?

My introduction to IEEE 754 was brought about via Python, when my chemistry kinetic simulations weren't running right (many millions of iterations, scaling factors with huge and tiny exponents). Understandi

## Re: (Score:2)

Isn't it fair to say that if you're worried about roundoff noise in repeated calculations, you've passed the point from being just a scientist to a someone who should be concerned with general programming theory and conventions, and hence at least familiar and comfortable with notation that denotes type?I understand types. The question here is which type the literal value "5" or "2" ought to be. Right now, these literals are interpreted as integers. A lot of people would prefer the default to be some real

## Re: (Score:2)

>> Right now, these literals are interpreted as integers

Not if you're using python 3 - it will treat numbers as floats if you divide with them. If you're not using python 3, you can have python 2.6 do the same:

>>> 5/2

2

>>> from __future__ import division

>>> 5/2

2.5

## Re: (Score:1)

## Re: (Score:3, Insightful)

That's why I don't like Matlab. Not only you have to import every single function you use, but each function comes in a separate file. And when you find the function you need on the web, you have to shell out an extra $5k to get the libraries it depends on.

My only worry about Python is that version 3 abomination. They not only managed to make each change towards a more complicated way to use, but also deprecated such a basic thing as string formattin

## Re: (Score:3, Informative)

bcook@bcook-box:~$ python3

Python 3.1.2 (r312:79147, Apr 15 2010, 15:35:48)

[GCC 4.4.3] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> "%d %s" % (1, "Hello")

'1 Hello'

## Re: (Score:2)

The original plan was to completely eliminate the '%' string formatting operator by version 3.2

I don't know if they are still committed to this, since, as I mentioned, this is one of the stupidest decisions one can imagine. But they still mention in the str.format method documentation that "This method of string formatting is the new standard in Python 3.0, and should be preferred to the % formatting described in String Formatting Operations in new code."

In the PEP-3101 documentation the abstract says: "Thi

## Re: (Score:1)

## Re: (Score:1)

Changes Already Present In Python 2.6. String formatting is deprecated in favor of their new horrible way. They're going to try to get rid of the old, good way. I won't switch to 3.0 unless they give up on that, but so far they haven't.## Re: (Score:2)

What kind of a scientist doesn't include at least 2 significant digits?

>>> 5.0/2.0

2.5

Problem solved

## Re: (Score:2)

For math:

from __future__ import division

## Re: (Score:2, Interesting)

## Re: (Score:2)

I don't want to load 20 modules before I can begin coding. I just want to input my algorithm and get a result I expectIn the real world of scientific programming, that's often not enough. A lot of scientific software needs to collect data from instruments, parse, format, deal with databases, perform visualizations, present user interfaces to lab assistants, interface with foreign libraries, etc. It needs to be unit tested, regression tested, maintained, reused, refactored, etc. Scientific libraries ofte

## What about APL? (Score:2)

## To all you C++ flamers... (Score:2)

Python threads seem to bring the C++ flamers out of the woodwork. Just so you know, Matplotlib is written in C++. I happen to like both languages.

## Re: (Score:1, Insightful)

## Alternative to matplotlib (Score:1, Interesting)

## Python..meh (Score:1, Funny)

No word yet if the chapters are indented properly.

## This book claims publication quality plots... (Score:3, Informative)

I have used matplotlib for journal plots and actually gave away a copy at a conference I ran so I have to say I really do like the book overall, but if you scan through the pages, you might be turned off.

## In Defense of Matlab (Score:3, Informative)

Python has it's strengths, but there are good reasons Matlab is so widely used:

Price: There is a price to everything, Matlab's is up-front and what you get is guaranteed support and development. If there is a bug or serious shortcoming you know someone is working on it like their job depends on it. .Net calls can be made from the Matlab command line, integrating compiled C is well-supported and very straightforward. Python can do these things, but it's not automatic or well-documented.

Graphics: Matlab has the most feature-rich and usable graphical environment of any of its would-be competitors, none of which do 3D well.

Speed: Core Matlab operations are highly optimized in C; properly vectorized Matlab code will run much faster than what most programmers could write in C themselves.

Interoperability: Java and

Documentation: it's there, and it's good.

Dev Environment: the debugging tools, profiler, and lint integration are really helpful.

## Re: (Score:2)

I'm not disagreeing with you per se, as I'm not extremely experienced in Matlab, but my empirical observations (working on my own code here) have shown that this isnt really true. I have recently written identical pieces of code in Matlab and Python/Numpy, with the same level of vectorisation I spose, and found Numpy to be significantly faster a

## Re: (Score:1)

This begs to differ if python is really interpreted anymore? Java and .NETs CLR use bytecode and JIT so the speed differences are not that big or at all unless you continuously load and unload large amounts of code. If its only a 10% difference then upgrading your cpu can bring the same effect. I wonder how fast python is and what kind of compiler or interpreter it is as well.

## Re: (Score:2)

It's not Matlab competing with raw Python in your example, but with the compiled C and Fortran of NumPy. They're going to be about the same speed. Matlab and Python are both interpretive languages, so pretty slow. However, the slowest most intensive parts have been compiled to get the "best" of both worlds, ease of use and speed.

## Re: (Score:2)

Wait, wait, wait. Are you saying "Yes, NumPy and Matlab work the same way, so no advantage to Matlab," or are you saying "the comparison isn't fair because compiled-C/Fortran routines being called by Numpy are being compared to compiled-C/Fortran routines being called by Matlab?"

If you're saying the latter, you need to know that the two software packages pretty much work the same way, you write a quick script and the array (vector) data is passed into a compiled routine to munch on and only when the routine

## Re: (Score:2)

Not the same, but very similar. As far as I'm aware Matlab uses a Fortran backend, while Numpy uses C. Now thats kind of picking at straws, but my point is honestly I don't think Matlab is faster than Python.

Either way I guess it depends on your toolbox in Matlab, or library in Python. Given both I'd choose Python every day of the week.

## Re: (Score:3, Interesting)

Speed in interpreted languages such as Python and Matlab depends strongly on what it is doing exactly, and how it is done. For example, both Matlab and the numpy Python module use external, pre-compiled, and highly optimized basic linear algebra subroutines (BLAS) for things like matrix multiplication. Matlab ships with several different BLAS, but it's even possible for Matlab to use the ATLAS BLAS which numpy uses.

So the speed would be the same in that case, assuming both your Matlab installation and numpy

## Re: (Score:1)

It integrates with command line very poorly (on windows).

The java interface parts look like shit.

The language sucks for real development work.

They want to pay them a fee to retain the future ability to purchase toolboxes, even though I don't want support.

The only thing I am still using is the griddata function because it is better than octaves.

Most of my work is now in python with gnuplot.

## Re: (Score:2)

Gnuplot is solid, I'm surprised I don't hear of it with Python. How do you connect them? My impression was there isn't a good link available.

## Re: (Score:1, Interesting)

For me, gnuplot is the best plotting program out there. It's very easy to use from python using Gnuplot.py (http://gnuplot-py.sourceforge.net). It essentially starts a gnuplot session that sends it commands through a pipe. You can choose if data is sent through a FIFO or temporary files (slower, but required for some of the interactive plotting features).

In a nutshell:

import Gnuplot as gp

g=gp.Gnuplot()

g.plot("sin(x)")

Conversion of most sensible python data types is done on the fly:

g.plot( [(x,x**2) for x in

## Re: (Score:1)

Not to mention using it with simulink, which is pretty impressive.

Also the differential equation solvers are pretty smart, if you need them.

Plus we use it with the symbolic math toolbox, which is very powerful and as far as I know there is no free replacement for it. Not that I would expect there to be, symbolic math is pretty hard to program I should think. The last free one I tried didn't even know that cos^2+sin^2 == 1

## Re: (Score:2)

Look into the libraries that Sage Math uses for near-Mathematica symbolic manipulation. Or just use Sage (which is built on top of Python).

Simulink I haven't found a great replacement for within Python, but graphical programming is often more of an impediment than a help for me. For layout of one-off control systems, it was nice, but I've just gotten too efficient with text editing (and I'm to the point that I can visualize what's going on) to want to worry about connecting wires, double-clicking, changing

## Re: (Score:2)

Price:

That's a positive? You can't even get a price unless you create an account with them and "login". Unless whoever you're doing the research for provides you with the budget or has it someplace you can get to it (and has bought the seats so you aren't fighting everyone for your chance to use it) you're going to be shelling out some cash.

As far as working on bugs or shortcomings, your not guaranteed anything. Like any other product your bug/feature/whatever goes into a priority queue. If you're a lowly grad st

## Re: (Score:2)

Check your comparison facts:

1) Near-compiled speed with a scripting front-end? Try NumPy out, it works the SAME WAY as Matlab (vectorize your code and it runs at near-compiled speed). There isn't any secret to how Matlab does things, it's just what they've put together into one package and the loyal userbase that keeps them going.

2) UI's: iPython or Spyder are user interfaces achieving similar goals to that of Matlab (I prefer the former as I'm a command-line junkie, but the latter will make you believe you

## Re: (Score:1)

Graphics: Matlab has the most feature-rich and usable graphical environment of any of its would-be competitors, none of which do 3D well.

I'm interpreting that to say that Matlab does a better job at 3D than the competitors, which is exactly the opposite of my experiences.

I work 100% in Python/Scipy/etc, and my brother does 100% Matlab. He had to come to me for suggestions when Matlab failed to handle visualization of his extremely large 3D datasets (I can't comment on whether he really had exhausted Matlab's functionality for that purpose). Although it's true that Matplotlib has pretty poor 3D support, Python gives you many more avenues: B

## Re: (Score:3, Interesting)

A few quick comments on this well-informed post...

Price: you're right here, Matlab is expensive and is locking you down, but at least you get very decent support from The MathWorks.

Graphics: Matlab has a huge library of very usable graphics functions. However it is nonetheless lacking in certain areas. GUIs is one of them (you can only embed Matlab graphics in a Matlab GUI, and the various methods to build a GUI in Matlab mostly sucks compared to what is possible outside of Matlab). Also, while Matlab figur

## Re: (Score:2)

Graphics: Matlab has a huge library of very usable graphics functions. However it is nonetheless lacking in certain areas. GUIs is one of them (you can only embed Matlab graphics in a Matlab GUI, and the various methods to build a GUI in Matlab mostly sucks compared to what is possible outside of Matlab).

It took me a long time to figure out Matlab graphics. Their "guide" function is nice for mocking up GUIs, but is not anything you want to use for making them. Handle graphics should be used the way they were originally designed; as OO objects managed by set and get. Since then I haven't found anything I want to do with Matlab graphics that I can't. It is total control.

Dev environment: All functions in all toolboxes are in the same namespace in Matlab, and it's beginning hard to find creative new names for my own function, all the most if they replicate some Matlab's built-in capability. Python's namespace / module imports solves this problem very nicely.

Yup, been an issue for awhile. However the 2008 class-definition and package-definition components go a long way to address it. They're movin

## Re: (Score:1)

Toolboxes: The set of toolboxes available for MATLAB is rich, capable, and documented. Yes, if I hack enough things together there are packages available for other languages that can do some of what MATLAB toolboxes can do. But at the end of the day, when I need to design filter coefficients, find a stabilizing gain, etc. I turn to MATLAB because it's there, I don't have to hunt for the packages, the results are repeatable on a different machine with a different version of MATLAB, and## Re: (Score:2)

the reason why matlab is so widely used is the same as the reason why FORTAN is widely used: there was an era when it truly was the best tool available... but because it's the only thing that the instructors know how to use.

Ya, momentum is definitely part of why Matlab is popular, but you ignore all of the other reasons I list, which are significant. Those are features you just can't get in a single package elsewhere.

I don't expect Matlab to be king forever, it is showing its age and there are many contenders for the crown. Perhaps Python+ will be the succesor. But it's going to take more than momentum to get there, the community will need to address the feature gap, and offer clearer advantages than "free".

## Re: (Score:2)

Check out Enthought's Python package, it includes amazing 3D visualization (on par with Matlab or superior, I think), the IDE you like from Matlab, good support, good documentation, etc. I don't think that Matlab has much advantage except for certain application-specific software that has just happened to be designed to interoperate with Matlab.

The Enthought pricing page: http://www.enthought.com/products/epd_sublevels.php [enthought.com]

(But note that you can get most of the functionality of the software for free, just yo

## Re: (Score:2)

Like I said, most of the software is available completely free, just not directly from Enthought; they are responsible for much of SciPy, which is 100% FOSS. MayaVi 1.x is completely free. NumPy is completely free. Documentation for these is completely free.

The Enthought package that they put together, which includes MayaVi 2.x, is not free. But the parent poster wanted paid-for support, so I recommended the Enthought package. For another good free bundled package, check out python(x,y).

## Nice Post (Score:1)

## Gotta love AdSense (Score:2)

## Try Veusz for an easier life (Score:4, Interesting)

If you find matplotlib hard, try my Veusz [gna.org] python plotting package. It has a GUI you can build plots within. It is scriptable in python, and even the saved file format is a python script to generate the plot. It can read a variety of data formats.