Skip to content

Commit f723ef9

Browse files
committed
typos in README
1 parent eee476f commit f723ef9

File tree

1 file changed

+70
-27
lines changed

1 file changed

+70
-27
lines changed

README.md

Lines changed: 70 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Contents
22

3-
[About](#about)
4-
[Usage] (#usage)
5-
[Prereqs](#prereqs)
6-
[Building](#building)
7-
[Example](#example)
3+
* [About](#about)
4+
* [Usage](#usage)
5+
* [Prereqs](#prereqs)
6+
* [Building](#building)
7+
* [Example](#example)
88

99

1010
# About
@@ -23,33 +23,75 @@ of 2015-03-19 it has been tested with IPython version 1.2.1 on Ubuntu 14.04.
2323

2424
# Usage
2525

26-
Here we create some 1D data and plot it. The variable "A" will be available
27-
for working with in the IPython session, even after the C++ program finishes.
26+
First, create an IPython kernel session
2827

29-
CppMatplotlib mpl{"/path/to/kernel-NNN.json"};
30-
mpl.Connect();
28+
```
29+
$ ipython kernel --pylab
30+
NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.
3131
32-
// Create a nice curve
33-
std::vector<NumpyArray::dtype> raw_data;
34-
double x = 0.0;
35-
while (x < 3.14159 * 4) {
36-
raw_data.push_back(std::sin(x));
37-
x += 0.05;
38-
}
32+
... blah blah blah ...
3933
40-
// Send it to IPython for plotting
41-
NumpyArray data("A", raw_data);
42-
mpl.SendData(data);
43-
mpl.RunCode("plot(A)\n"
44-
"title('f(x) = sin(x)')\n"
45-
"xlabel('x')\n"
46-
"ylabel('f(x)')\n");
34+
To connect another client to this kernel, use:
35+
--existing kernel-NNN.json
36+
```
4737

48-
And the result will be ![Screenshot](screenshot.png?raw=true "Screenshot of
49-
sin(x)")
38+
It is important to remember that NNN in the last line, which is the PID of the
39+
kernel. This JSON file is stored somewhere in your $HOME, exactly where can
40+
vary. Find it with <tt>find ~/ -name kernel-NNN.json</tt>.
41+
42+
Here we create some 1D data and plot it. The numpy.array "MyData" will be
43+
available for working with in the IPython session, even after the C++ program
44+
finishes.
45+
46+
```c++
47+
CppMatplotlib mpl{"/path/to/kernel-NNN.json"};
48+
mpl.Connect();
49+
50+
// Create a nice curve
51+
std::vector<NumpyArray::dtype> raw_data;
52+
double x = 0.0;
53+
while (x < 3.14159 * 4) {
54+
raw_data.push_back(std::sin(x));
55+
x += 0.05;
56+
}
57+
58+
// Send it to IPython for plotting
59+
NumpyArray data("MyData", raw_data);
60+
mpl.SendData(data);
61+
mpl.RunCode("plot(MyData)\n"
62+
"title('f(x) = sin(x)')\n"
63+
"xlabel('x')\n"
64+
"ylabel('f(x)')\n");
65+
66+
// NOTE: if you want to store the python in an external file, use the
67+
// convenience function LoadFile("my_code.py"), as in,
68+
// mpl.RunCode(LoadFile("plotting_code.py"));
69+
```
70+
71+
And the result is ![Screenshot](screenshot.png?raw=true)
5072
5173
See [src/main.cc](src/main.cc) for a complete program.
5274
75+
To work with "MyData" you can connect to the kernel using an IPython console,
76+
notebook, or qtconsole:
77+
78+
```
79+
$ ipython console --existing kernel-NNN.json
80+
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
81+
Type "copyright", "credits" or "license" for more information.
82+
83+
IPython 1.2.1 -- An enhanced Interactive Python.
84+
? -> Introduction and overview of IPython's features.
85+
%quickref -> Quick reference.
86+
help -> Python's own help system.
87+
object? -> Details about 'object', use 'object??' for extra details.
88+
89+
In [1]: MyData *= 4
90+
91+
In [84]: print MyData[9]
92+
[ 1.73986214]
93+
```
94+
5395
5496
# Prereqs
5597
@@ -61,7 +103,7 @@ See [src/main.cc](src/main.cc) for a complete program.
61103
62104
# Building
63105
64-
git clone https://bitbucket.org/james_youngquist/cpp-matplotlib.git
106+
# git clone this repository to cpp-matplotlib/
65107
cd cpp-matplotlib
66108
mkdir build
67109
cd build
@@ -74,7 +116,8 @@ See [src/main.cc](src/main.cc) for a complete program.
74116
doxygen Doxyfile
75117
# open html/index.html
76118
77-
# Example
119+
120+
# Running the Example
78121
79122
In terminal 1:
80123

0 commit comments

Comments
 (0)