1 Star 0 Fork 2

sanqima/matplotlib-cpp

forked from lzc/matplotlib-cpp 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
lines3d.cpp 850 Bytes
一键复制 编辑 原始数据 按行查看 历史
Kenta Yonekura 提交于 2021-04-13 10:20 +08:00 . Fix a missing M_PI in windows environment
#define _USE_MATH_DEFINES
#include "../matplotlibcpp.h"
#include <cmath>
namespace plt = matplotlibcpp;
int main()
{
std::vector<double> x, y, z;
double theta, r;
double z_inc = 4.0/99.0; double theta_inc = (8.0 * M_PI)/99.0;
for (double i = 0; i < 100; i += 1) {
theta = -4.0 * M_PI + theta_inc*i;
z.push_back(-2.0 + z_inc*i);
r = z[i]*z[i] + 1;
x.push_back(r * sin(theta));
y.push_back(r * cos(theta));
}
std::map<std::string, std::string> keywords;
keywords.insert(std::pair<std::string, std::string>("label", "parametric curve") );
plt::plot3(x, y, z, keywords);
plt::xlabel("x label");
plt::ylabel("y label");
plt::set_zlabel("z label"); // set_zlabel rather than just zlabel, in accordance with the Axes3D method
plt::legend();
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

搜索帮助