44* [ Usage] ( #usage )
55* [ Prereqs] ( #prereqs )
66* [ Building] ( #building )
7- * [ Example] ( #example )
7+ * [ Running the Example] ( #running-the- example )
88
99
1010# About
1111
12- An easy-to-use library for simple plotting from C++ via a ZeroMQ bridge to
13- an [ IPython] ( http://ipython.org/ ) kernel.
12+ An easy-to-use ** C++11 ** library for simple plotting from C++ via a ZeroMQ
13+ bridge to an [ IPython] ( http://ipython.org/ ) kernel.
1414
1515It provides the ability to send [ NumPy] ( http://www.numpy.org/ ) array
1616compatible data to an IPython kernel session as well as execute arbitrary
@@ -43,29 +43,39 @@ Here we create some 1D data and plot it. The numpy.array "MyData" will be
4343available for working with in the IPython session, even after the C++ program
4444finishes.
4545
46+ All library code lives in the <tt >cppmpl</tt > namespace.
47+
4648``` 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;
49+ #include " cpp_mpl.hpp"
50+
51+ int main () {
52+ // ...
53+
54+ cppmpl::CppMatplotlib mpl{"/path/to/kernel-NNN.json"};
55+ mpl.Connect();
56+
57+ // Create a nice curve
58+ std::vector< cppmpl::NumpyArray::dtype > raw_data;
59+ double x = 0.0;
60+ while (x < 3.14159 * 4) {
61+ raw_data.push_back(std::sin(x));
62+ x += 0.05;
63+ }
64+
65+ // Send it to IPython for plotting
66+ cppmpl::NumpyArray data("MyData", raw_data);
67+ mpl.SendData(data);
68+ mpl.RunCode("plot(MyData)\n"
69+ "title('f(x) = sin(x)')\n"
70+ "xlabel('x')\n"
71+ "ylabel('f(x)')\n");
72+
73+ // NOTE: if you want to store the python in an external file, use the
74+ // convenience function LoadFile("my_code.py"), as in,
75+ // mpl.RunCode(cppmpl::LoadFile("plotting_code.py"));
76+
77+ // ...
5678}
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"));
6979```
7080
7181And the result is ![ Screenshot] ( screenshot.png?raw=true )
@@ -92,6 +102,17 @@ In [84]: print MyData[9]
92102[ 1.73986214]
93103```
94104
105+ ## Compiling / Linking
106+
107+ When linking against <tt >cpp_plot.{a,so}</tt >, you also need to link against
108+ libzmq, libjsoncpp, libuuid, and libcripto:
109+
110+ ```
111+ $ g++ my_prog.cc -std=c++11 /path/to/libcpp_plot.a -ljsoncpp -lzmq -luuid -lcrypto
112+ ```
113+
114+ Or just modify CMakeFiles.txt...
115+
95116
96117# Prereqs
97118
0 commit comments