FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib-cpp/examples/modern.cpp at master · fool404/matplotlib-cpp · GitHub
fool404
/
matplotlib-cpp
Public
forked from
lava/matplotlib-cpp
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib-cpp
/
examples
/
modern.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (24 loc) · 812 Bytes
Breadcrumbs
matplotlib-cpp
/
examples
/
modern.cpp
Copy path
File metadata and controls
30 lines (24 loc) · 812 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
#
define
_USE_MATH_DEFINES
#
include
<
cmath
>
#
include
"
../matplotlibcpp.h
"
using
namespace
std
;
namespace
plt
=
matplotlibcpp;
int
main
()
{
//
plot(y) - the x-coordinates are implicitly set to [0,1,...,n)
//
plt::plot({1,2,3,4});
//
Prepare data for parametric plot.
int
n =
5000
;
//
number of data points
vector<
double
>
x
(n),
y
(n);
for
(
int
i=
0
; i<n; ++i) {
double
t =
2
*
M_PI
*i/n;
x.
at
(i) =
16
*
sin
(t)*
sin
(t)*
sin
(t);
y.
at
(i) =
13
*
cos
(t) -
5
*
cos
(
2
*t) -
2
*
cos
(
3
*t) -
cos
(
4
*t);
}
//
plot() takes an arbitrary number of (x,y,format)-triples.
//
x must be iterable (that is, anything providing begin(x) and end(x)),
//
y must either be callable (providing operator() const) or iterable.
plt::plot
(x, y,
"
r-
"
, x, [](
double
d) {
return
12.5
+
abs
(
sin
(d)); },
"
k-
"
);
//
show plots
plt::show
();
}
Back
|
FazBrowse Home
|
New Git URL