Skip to content

Commit eae3824

Browse files
author
Benno Evers
committed
Add picture and cpp file for new surface example.
1 parent 69e58fe commit eae3824

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
examples: minimal basic modern animation nonblock xkcd quiver bar
1+
examples: minimal basic modern animation nonblock xkcd quiver bar surface
22

33
minimal: examples/minimal.cpp matplotlibcpp.h
44
cd examples && g++ -DWITHOUT_NUMPY minimal.cpp -I/usr/include/python2.7 -lpython2.7 -o minimal -std=c++11
@@ -24,5 +24,8 @@ xkcd: examples/xkcd.cpp matplotlibcpp.h
2424
bar: examples/bar.cpp matplotlibcpp.h
2525
cd examples && g++ bar.cpp -I/usr/include/python2.7 -lpython2.7 -o bar -std=c++11
2626

27+
surface: examples/surface.cpp matplotlibcpp.h
28+
cd examples && g++ surface.cpp -I/usr/include/python2.7 -lpython2.7 -o surface -std=c++11
29+
2730
clean:
2831
rm -f examples/{minimal,basic,modern,animation,nonblock,xkcd,quiver,bar}

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ int main()
173173
for (double j = -5; j <= 5; j += 0.25) {
174174
x_row.push_back(i);
175175
y_row.push_back(j);
176-
z_row.push_back(::std::sin(::std::hypot(x, y)));
176+
z_row.push_back(::std::sin(::std::hypot(i, j)));
177177
}
178178
x.push_back(x_row);
179179
y.push_back(y_row);
@@ -185,6 +185,10 @@ int main()
185185
}
186186
```
187187

188+
**Result:**
189+
190+
![surface example](./examples/surface.png)
191+
188192
Installation
189193
------------
190194

examples/surface.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "../matplotlibcpp.h"
2+
3+
#include <cmath>
4+
5+
namespace plt = matplotlibcpp;
6+
7+
int main()
8+
{
9+
std::vector<std::vector<double>> x, y, z;
10+
for (double i = -5; i <= 5; i += 0.25) {
11+
std::vector<double> x_row, y_row, z_row;
12+
for (double j = -5; j <= 5; j += 0.25) {
13+
x_row.push_back(i);
14+
y_row.push_back(j);
15+
z_row.push_back(::std::sin(::std::hypot(i, j)));
16+
}
17+
x.push_back(x_row);
18+
y.push_back(y_row);
19+
z.push_back(z_row);
20+
}
21+
22+
plt::plot_surface(x, y, z);
23+
plt::show();
24+
}

examples/surface.png

104 KB
Loading

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy