@@ -41,15 +41,18 @@ int main()
4141 z.at(i) = log(i);
4242 }
4343
44+ // Set the size of output image to 1200x780 pixels
45+ plt::figure_size(1200, 780);
4446 // Plot line from given x and y data. Color is selected automatically.
4547 plt::plot(x, y);
4648 // Plot a red dashed line from given x and y data.
4749 plt::plot(x, w,"r--");
4850 // Plot a line whose name will show up as "log(x)" in the legend.
4951 plt::named_plot("log(x)", x, z);
50-
5152 // Set x-axis to interval [0,1000000]
5253 plt::xlim(0, 1000*1000);
54+ // Add graph title
55+ plt::title("Sample figure");
5356 // Enable legend.
5457 plt::legend();
5558 // Save the image (file format is determined by the extension)
@@ -58,9 +61,11 @@ int main()
5861```
5962 g++ basic.cpp -I/usr/include/python2.7 -lpython2.7
6063
61- Result: ![ Basic example] ( ./examples/basic.png )
64+ ** Result:**
65+
66+ ![ Basic example] ( ./examples/basic.png )
6267
63- matplotlib-cpp doesn't require C++11, but will enable some additional syntactic sugar when available :
68+ Alternatively, matplotlib-cpp also supports some C++11-powered syntactic sugar:
6469``` cpp
6570#include < cmath>
6671#include " matplotlibcpp.h"
@@ -91,7 +96,9 @@ int main()
9196```
9297 g++ modern.cpp -std=c++11 -I/usr/include/python2.7 -lpython
9398
94- Result: 
99+ **Result:**
100+
101+ 
95102
96103Or some *funny-looking xkcd-styled* example:
97104```cpp
@@ -121,7 +128,66 @@ int main() {
121128
122129** Result:**
123130
124- ![ Minimal example] ( ./examples/xkcd.png )
131+ ![ xkcd example] ( ./examples/xkcd.png )
132+
133+ When working with vector fields, you might be interested in quiver plots:
134+ ``` cpp
135+ #include " ../matplotlibcpp.h"
136+
137+ namespace plt = matplotlibcpp;
138+
139+ int main()
140+ {
141+ // u and v are respectively the x and y components of the arrows we're plotting
142+ std::vector<int> x, y, u, v;
143+ for (int i = -5; i <= 5; i++) {
144+ for (int j = -5; j <= 5; j++) {
145+ x.push_back(i);
146+ u.push_back(-i);
147+ y.push_back(j);
148+ v.push_back(-j);
149+ }
150+ }
151+
152+ plt::quiver (x, y, u, v);
153+ plt::show();
154+ }
155+ ```
156+ g++ quiver.cpp -std=c++11 -I/usr/include/python2.7 -lpython2.7
157+
158+ **Result:**
159+
160+ 
161+
162+ When working with 3d functions, you might be interested in 3d plots:
163+ ```cpp
164+ #include "../matplotlibcpp.h"
165+
166+ namespace plt = matplotlibcpp;
167+
168+ int main()
169+ {
170+ std::vector<std::vector<double>> x, y, z;
171+ for (double i = -5; i <= 5; i += 0.25) {
172+ std::vector<double> x_row, y_row, z_row;
173+ for (double j = -5; j <= 5; j += 0.25) {
174+ x_row.push_back(i);
175+ y_row.push_back(j);
176+ z_row.push_back(::std::sin(::std::hypot(i, j)));
177+ }
178+ x.push_back(x_row);
179+ y.push_back(y_row);
180+ z.push_back(z_row);
181+ }
182+
183+ plt::plot_surface(x, y, z);
184+ plt::show();
185+ }
186+ ```
187+
188+ ** Result:**
189+
190+ ![ surface example] ( ./examples/surface.png )
125191
126192Installation
127193------------
@@ -150,6 +216,16 @@ find_package(PythonLibs 2.7)
150216target_include_directories(myproject PRIVATE ${PYTHON_INCLUDE_DIRS})
151217target_link_libraries(myproject ${PYTHON_LIBRARIES})
152218```
219+
220+ # C++11
221+
222+ Currently, c++11 is required to build matplotlib-cpp. The last working commit that did
223+ not have this requirement was ` 717e98e752260245407c5329846f5d62605eff08 ` .
224+
225+ Note that support for c++98 was dropped more or less accidentally, so if you have to work
226+ with an ancient compiler and still want to enjoy the latest additional features, I'd
227+ probably merge a PR that restores support.
228+
153229# Python 3
154230
155231This library supports both python2 and python3 (although the python3 support is probably far less tested,
0 commit comments