Skip to content

Commit 0f382b3

Browse files
author
Christoph Jenzen
committed
Added Eventplot + Reformatting
1 parent 717e98e commit 0f382b3

File tree

3 files changed

+214
-96
lines changed

3 files changed

+214
-96
lines changed

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
examples: minimal basic modern animation nonblock xkcd
1+
examples: minimal basic eventplot modern animation nonblock xkcd
22

33
minimal: examples/minimal.cpp matplotlibcpp.h
44
cd examples && g++ -DWITHOUT_NUMPY minimal.cpp -I/usr/include/python2.7 -lpython2.7 -o minimal -std=c++11
55

66
basic: examples/basic.cpp matplotlibcpp.h
7-
cd examples && g++ basic.cpp -I/usr/include/python2.7 -lpython2.7 -o basic
7+
cd examples && g++ basic.cpp -I/usr/include/python2.7 -lpython2.7 -o basic -std=c++11
8+
9+
eventplot: examples/eventplot.cpp matplotlibcpp.h
10+
cd examples && g++ eventplot.cpp -I/usr/include/python2.7 -lpython2.7 -o eventplot -std=c++11 -g
811

912
modern: examples/modern.cpp matplotlibcpp.h
1013
cd examples && g++ modern.cpp -I/usr/include/python2.7 -lpython2.7 -o modern -std=c++11
@@ -19,4 +22,4 @@ xkcd: examples/xkcd.cpp matplotlibcpp.h
1922
cd examples && g++ xkcd.cpp -I/usr/include/python2.7 -lpython2.7 -o xkcd -std=c++11
2023

2124
clean:
22-
rm -f examples/{minimal,basic,modern,animation,nonblock,xkcd}
25+
rm -f examples/{minimal,basic,modern,animation,nonblock,xkcd,eventplot}

examples/eventplot.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#define _USE_MATH_DEFINES
2+
#include <iostream>
3+
#include <cmath>
4+
#include "../matplotlibcpp.h"
5+
6+
namespace plt = matplotlibcpp;
7+
8+
int main()
9+
{
10+
// Prepare data.
11+
std::vector<std::vector<double>> events;
12+
events.push_back({2,5,10,25});
13+
events.push_back({20,21,22,24});
14+
events.push_back({4,8,12,14,16,17,18});
15+
events.push_back({10,11,12,13.5});
16+
17+
18+
19+
// Set the size of output image = 1200x780 pixels
20+
plt::figure_size(1200, 780);
21+
22+
plt::eventplot(events);
23+
24+
// Add graph title
25+
plt::title("Event plot");
26+
plt::xlabel("Time in ms");
27+
plt::ylabel("Neuron ID");
28+
29+
plt::show();
30+
// save figure
31+
const char* filename = "./events.png";
32+
std::cout << "Saving result to " << filename << std::endl;;
33+
plt::save(filename);
34+
}

0 commit comments

Comments
 (0)