linux系统不会调用matplotlincpp.h想用c++画这种统计图表

x = (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,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63)

y = (4183,4191,4201,4204,4198,4200,4204,4204,4201,4197,4195,4195,4196,4196,4197,4204,4220,4226,4232,4240,4248,4255,4264,4265,4265,4270,4271,4271,4267,4266,4266,4265,4260,4257,4254,4249,4248,4251,4253,4252,4250,4249,4250,4248,4249,4255,4262,4267,4272,4277,4279,4280,4282,4285,4288,4294,4300,4300,4300,4302,4305,4308)

z = (76,65,77,59,55,58,60,50,37,24,36,50,52,51,57,86,87,78,78,86,80,80,82,56,48,54,52,48,46,48,46,46,53,52,47,62,72,68,65,53,59,65,62,60,68,70,71,65,56,56,55,60,62,60,68,68,50,49,59,60,61,60,59)

img

搜了些Cmake添加文件头文档没看懂,我是外行学了两天python不喜欢用,就来学c++,我用的ubuntu系统vim g++

  安装了python

img

安装了matplotlincpp

img

安装了cmake

img

img

#include <vector>
#include "matplotlibcpp.h"

namespace plt = matplotlibcpp;

int main() {
  std::vector<int> x = {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, 36, 37, 38, 39,
                        40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
                        53, 54, 55, 56, 57, 58, 59, 60, 61, 62};

  std::vector<int> y = {4183, 4191, 4201, 4204, 4198, 4200, 4204, 4204, 4201,
                        4197, 4195, 4195, 4196, 4196, 4197, 4204, 4220, 4226,
                        4232, 4240, 4248, 4255, 4264, 4265, 4265, 4270, 4271,
                        4271, 4267, 4266, 4266, 4265, 4260, 4257, 4254, 4249,
                        4248, 4251, 4253, 4252, 4250, 4249, 4250, 4248, 4249,
                        4255, 4262, 4267, 4272, 4277, 4279, 4280, 4282, 4285,
                        4288, 4294, 4300, 4300, 4300, 4302, 4305, 4308};

  std::vector<int> z = {76, 65, 77, 59, 55, 58, 60, 50, 37, 24, 36, 50, 52,
                        51, 57, 86, 87, 78, 78, 86, 80, 80, 82, 56, 48, 54,
                        52, 48, 46, 48, 46, 46, 53, 52, 47, 62, 72, 68, 65,
                        53, 59, 65, 62, 60, 68, 70, 71, 65, 56, 56, 55, 60,
                        62, 60, 68, 68, 50, 49, 59, 60, 61, 60};
  plt::figure();
  plt::subplot2grid(2, 1, 0, 0);
  plt::plot(x, y, "r.-");
  plt::subplot2grid(2, 1, 1, 0);
  plt::plot(x, z, "b.-");
  plt::show();
  return 0;
}

img

不知道我的回答可不可以帮到你

#include <vector>
#include "matplotlibcpp.h"
 
namespace plt = matplotlibcpp;
 
int main() {
  std::vector<int> x = {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, 36, 37, 38, 39,
                        40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
                        53, 54, 55, 56, 57, 58, 59, 60, 61, 62};
 
  std::vector<int> y = {4183, 4191, 4201, 4204, 4198, 4200, 4204, 4204, 4201,
                        4197, 4195, 4195, 4196, 4196, 4197, 4204, 4220, 4226,
                        4232, 4240, 4248, 4255, 4264, 4265, 4265, 4270, 4271,
                        4271, 4267, 4266, 4266, 4265, 4260, 4257, 4254, 4249,
                        4248, 4251, 4253, 4252, 4250, 4249, 4250, 4248, 4249,
                        4255, 4262, 4267, 4272, 4277, 4279, 4280, 4282, 4285,
                        4288, 4294, 4300, 4300, 4300, 4302, 4305, 4308};
 
  std::vector<int> z = {76, 65, 77, 59, 55, 58, 60, 50, 37, 24, 36, 50, 52,
                        51, 57, 86, 87, 78, 78, 86, 80, 80, 82, 56, 48, 54,
                        52, 48, 46, 48, 46, 46, 53, 52, 47, 62, 72, 68, 65,
                        53, 59, 65, 62, 60, 68, 70, 71, 65, 56, 56, 55, 60,
                        62, 60, 68, 68, 50, 49, 59, 60, 61, 60};
  plt::figure();
  plt::subplot2grid(2, 1, 0, 0);
  plt::plot(x, y, "r.-");
  plt::subplot2grid(2, 1, 1, 0);
  plt::plot(x, z, "b.-");
  plt::show();
  return 0;
}