Gregor von Laszewski, laszewski@gmail.com
This ipython script demonstrates how easy it is to interface java and python with ipython by using ipython as shell and postprocessing the data with matplotlib and/or pandas
The code to this ipython notebook can be found at
In particular this notebook is in
The java code is in
Several libraries may not yet be installed. Make sure you have jsonsche,ma and pandas
In [ ]:
pip install jsonschema
In [ ]:
pip install pandas
In [1]:
!pwd
In [2]:
!cd java; rm -f data.csv *.class *~
In [3]:
!which java
The program we use will just print a small number of values in csv format into a file so we can read it for plotting
In [4]:
!ls java
Looking at the contenst of the file java/data.java
In [5]:
!cat java/data.java
Compiling the code
In [6]:
!cd java; javac data.java
Looking at the output
In [7]:
!ls java/*.class
In [8]:
!cd java; java data
Looking if the data is created
In [9]:
!cat java/data.csv
Enable inline plotting
In [10]:
%pylab inline
Importing the usual plotting libraries
In [12]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
Reading the data from csv
In [15]:
data = pd.read_csv('java/data.csv')
In [16]:
print data
Creating the Data frame
In [17]:
df = pd.DataFrame(data, columns=['x', 'y'])
In [18]:
df
Out[18]:
In [19]:
plt.scatter(df.x, df.y)
Out[19]:
In [ ]: