Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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 :

http://mathematica.stackexchange.com/questions/1010/2d-gaussian-distribution-of-squares-coordinates#comment2475_1010

share|improve this question
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 Jan 31 '12 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 Jan 31 '12 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 Feb 1 '12 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')
ax1.set_xticks([])
ax1.set_yticks([])
MPL.show()

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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