FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib-cpp/examples/fill.cpp at master · lava/matplotlib-cpp · GitHub
lava
/
matplotlib-cpp
Public
Notifications
You must be signed in to change notification settings
Fork
1.2k
Star
4.8k
Code
Issues
192
Pull requests
31
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib-cpp
/
examples
/
fill.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (28 loc) · 951 Bytes
Breadcrumbs
matplotlib-cpp
/
examples
/
fill.cpp
Copy path
File metadata and controls
35 lines (28 loc) · 951 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#
define
_USE_MATH_DEFINES
#
include
"
../matplotlibcpp.h
"
#
include
<
cmath
>
using
namespace
std
;
namespace
plt
=
matplotlibcpp;
//
Example fill plot taken from:
//
https://matplotlib.org/gallery/misc/fill_spiral.html
int
main
() {
//
Prepare data.
vector<
double
> theta;
for
(
double
d =
0
; d <
8
*
M_PI
; d +=
0.1
)
theta.
push_back
(d);
const
int
a =
1
;
const
double
b =
0.2
;
for
(
double
dt =
0
; dt <
2
*
M_PI
; dt +=
M_PI
/
2.0
) {
vector<
double
> x1, y1, x2, y2;
for
(
double
th : theta) {
x1.
push_back
( a*
cos
(th + dt) *
exp
(b*th) );
y1.
push_back
( a*
sin
(th + dt) *
exp
(b*th) );
x2.
push_back
( a*
cos
(th + dt +
M_PI
/
4.0
) *
exp
(b*th) );
y2.
push_back
( a*
sin
(th + dt +
M_PI
/
4.0
) *
exp
(b*th) );
}
x1.
insert
(x1.
end
(), x2.
rbegin
(), x2.
rend
());
y1.
insert
(y1.
end
(), y2.
rbegin
(), y2.
rend
());
plt::fill
(x1, y1, {});
}
plt::show
();
}
Back
|
FazBrowse Home
|
New Git URL