1 Star 0 Fork 2

sanqima/matplotlib-cpp

forked from lzc/matplotlib-cpp 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
imshow.cpp 662 Bytes
一键复制 编辑 原始数据 按行查看 历史
Trevor Keller 提交于 2019-05-08 12:45 +08:00 . Added basic example for imshow.
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include "../matplotlibcpp.h"
using namespace std;
namespace plt = matplotlibcpp;
int main()
{
// Prepare data
int ncols = 500, nrows = 300;
std::vector<float> z(ncols * nrows);
for (int j=0; j<nrows; ++j) {
for (int i=0; i<ncols; ++i) {
z.at(ncols * j + i) = std::sin(std::hypot(i - ncols/2, j - nrows/2));
}
}
const float* zptr = &(z[0]);
const int colors = 1;
plt::title("My matrix");
plt::imshow(zptr, nrows, ncols, colors);
// Show plots
plt::save("imshow.png");
std::cout << "Result saved to 'imshow.png'.\n";
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/docplus/matplotlib-cpp.git
git@gitee.com:docplus/matplotlib-cpp.git
docplus
matplotlib-cpp
matplotlib-cpp
master

搜索帮助