views:

57

answers:

2

I'm looking for some tool/library that is able to draw simple 2d geometries from text file or programatically. I already found List of interactive geometry software but that not quite what I'm looking for. I would prefer something more similar in usage to graphviz or gnuplot. I already wrote some scripts for gnuplot but this tool has been designed for different purposes. Required functionality:

  • support for different kind of 2D geometries: points, segments, lines, circles, polygons
  • simple input type format maybe similar to postgis Well Known Text
  • support for objects additional data like tags and colors definition
  • output in common image format or some kind of interactive GUI (with zoom in/out and select object)
  • configurable grid
  • autoscale or draw in defined area

I will use it for testing geometry algorithms and don't want to reinvent the wheel.

A: 

Maybe dia, with it's SVG output option is what you're looking for? It can be scripted in Pyhton.

Omnifarious
I know dia but always have always thought about it as diagram/UML tool not geometry. Can you provide any tutorial on scripting dia in python?
jethro
@jethro - I've never done it. I just know it can be done. dia is rather poorly documented. :-(
Omnifarious
+2  A: 

Matplotlib. I'm not familiar with all the aspects of this Python library but I've heard it is pretty good.

To quote their introduction,

matplotlib is a python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms. matplotlib can be used in python scripts, the python and ipython shell (ala MATLAB®* or Mathematica®†), web application servers, and six graphical user interface toolkits.

matplotlib tries to make easy things easy and hard things possible. You can generate plots, histograms, power spectra, bar charts, errorcharts, scatterplots, etc, with just a few lines of code. For a sampling, see the screenshots, thumbnail gallery, and examples directory

Example outputs

For example, using "ipython -pylab" to provide an interactive environment, to generate 10,000 gaussian random numbers and plot a histogram with 100 bins, you simply need to type

x = randn(10000)
hist(x, 100)

For the power user, you have full control of line styles, font properties, axes properties, etc, via an object oriented interface or via a set of functions familiar to MATLAB users. The pylab mode provides all of the pyplot plotting functions listed below, as well as non-plotting functions from numpy and matplotlib.mlab.

Ashish
[This](http://matplotlib.sourceforge.net/examples/api/compound_path.html) example looks quite similar to what I want. I'm gonna give it a try.
jethro
I'm glad my answer was helpful. :)
Ashish
Did you finally use this?
Ashish