1 Star 0 Fork 2

sanqima/matplotlib-cpp

forked from lzc/matplotlib-cpp 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
fill.cpp 951 Bytes
一键复制 编辑 原始数据 按行查看 历史
Tobias Tschirch 提交于 2019-03-12 05:39 +08:00 . Add fill plot with example
#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();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/docplus/matplotlib-cpp.git
git@gitee.com:docplus/matplotlib-cpp.git
docplus
matplotlib-cpp
matplotlib-cpp
master

搜索帮助