@@ -41,17 +41,18 @@ int main()
4141 z.at(i) = log(i);
4242 }
4343
44- // Set the size of output image = 1200x780 pixels
44+ // Set the size of output image to 1200x780 pixels
4545 plt::figure_size(1200, 780);
4646 // Plot line from given x and y data. Color is selected automatically.
4747 plt::plot(x, y);
4848 // Plot a red dashed line from given x and y data.
4949 plt::plot(x, w,"r--");
5050 // Plot a line whose name will show up as "log(x)" in the legend.
5151 plt::named_plot("log(x)", x, z);
52-
5352 // Set x-axis to interval [0,1000000]
5453 plt::xlim(0, 1000*1000);
54+ // Add graph title
55+ plt::title("Sample figure");
5556 // Enable legend.
5657 plt::legend();
5758 // Save the image (file format is determined by the extension)
@@ -60,7 +61,9 @@ int main()
6061```
6162 g++ basic.cpp -I/usr/include/python2.7 -lpython2.7
6263
63- Result: ![ Basic example] ( ./examples/basic.png )
64+ ** Result:**
65+
66+ ![ Basic example] ( ./examples/basic.png )
6467
6568matplotlib-cpp doesn't require C++11, but will enable some additional syntactic sugar when available:
6669``` cpp
@@ -93,7 +96,9 @@ int main()
9396```
9497 g++ modern.cpp -std=c++11 -I/usr/include/python2.7 -lpython
9598
96- Result: 
99+ **Result:**
100+
101+ 
97102
98103Or some *funny-looking xkcd-styled* example:
99104```cpp
@@ -123,7 +128,36 @@ int main() {
123128
124129** Result:**
125130
126- ![ 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+ 
127161
128162Installation
129163------------
0 commit comments