I was wondering how I would go about using Python to create a Graph with Mathematica. I want to be able to use python code to invoke mathematica to create a new graph, using data from a CSV file.
-
Here's some hints: stackoverflow.com/questions/tagged/python+mathematica These may not be precisely what you want. But you could try using Google for additional resources.S.Lott– S.Lott2010-12-16 23:10:43 +00:00Commented Dec 16, 2010 at 23:10
-
Do you mean a graph as in graph theory or a graph as in a plot of some data?Simon– Simon2010-12-17 04:01:51 +00:00Commented Dec 17, 2010 at 4:01
3 Answers
The old fashioned way to do what Yaroslav suggested is to just call the kernel (math) with the script switch e.g. math -script graph.m. Where graph.m is either constructed beforehand and will load the csv file or is constructed on the fly by your python program.
Can I ask why you want to use Mathematica for making the graph? There are lots of python (and other) utilities that will do it for you. There are lots of options listed here: graph survey.
Comments
You probably need to look at PYML, which provides a Python API for Mathematica.
Depending on your needs, you might also want to look at matplotlib which would allow you to do the graphing in Python.