forked from lava/matplotlib-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheventplot.cpp
More file actions
36 lines (29 loc) · 893 Bytes
/
Copy patheventplot.cpp
File metadata and controls
36 lines (29 loc) · 893 Bytes
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
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include "../matplotlibcpp.h"
namespace plt = matplotlibcpp;
int main()
{
// Prepare data.
std::vector<std::vector<double>> events;
events.push_back({2,5,10,25});
events.push_back({20,21,22,24});
events.push_back({4,8,12,14,16,17,18});
events.push_back({10,11,12,13.5});
// Set the size of output image = 1200x780 pixels
plt::figure_size(1200, 780);
std::map<std::string, std::string> keywords;
keywords["linewidths"] = "0.5";
keywords["colors"] = "black";
plt::eventplot(events, keywords);
// Add graph title
plt::title("Event plot");
plt::xlabel("Time in ms");
plt::ylabel("Neuron ID");
plt::show();
// save figure
const char* filename = "./events.png";
std::cout << "Saving result to " << filename << std::endl;;
plt::save(filename);
}