Being only familiar with Mathematica and its Graphics, I have now to learn to draw Graphics using Python for a server.

Mostly conditional combination of simple shape.

What would be a package for Python that make drawing Graphics as close as possible as the Mathematica Graphics environment ?

For Example, I would need to do such thing as in :


  • 1
    First, having only just read the FAQ, I strongly suspect that this is a question more suited to StackOverflow. Second, you should probably take a step back before asking your question on SO--ask the question in the context of what you wish to achieve, and not in the context of what you think the solution might be.
    – Eric Smith
    Commented Jan 31, 2012 at 15:46
  • @Eric, I post that here, after suggestion it does not belong neither to So or Mathematica.... I believe I am asking the question in the context of what I am trying to achieve, since I show the type of things I need to do with it above....
    – 500
    Commented Jan 31, 2012 at 20:04
  • 1
    matplotlib, along with numpy and scipy, are the usual starting point for mathematical plotting, unless you wanted a more general graphics library
    – tsundoku
    Commented Feb 1, 2012 at 11:13

1 Answer 1


Matplotlib is what you want.

The special sauce is a rendering technology known as agg which i believe stands for anti-grain geometry. The results is that this library produces publication-quality graphics across a staggering range of plot families.

My plot isn't all that much like the one in linked to in your Question, but that's only because the colors are different.

That sort of plot is trivial in Matplotlib. Here's the code i used to create it.

import numpy as NP
from matplotlib import pyplot as MPL
import matplotlib.cm as CM

M = NP.random.randint(0, 25, 100**2).reshape(100, 100)
M = NP.where(M < 20, 0, M)

fig = MPL.figure(frameon='False')
ax1 = fig.add_subplot(111)
ax1.imshow(M, cmap=CM.Accent, interpolation='nearest')

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.