I think this might be a really easy question for someone that has already used gnuplot and "splot" command, but I can't figure it right now as this is my first day using this program.
I achived linking my c++ project to gnuplot, so I'm able to create a Datafile.dat with this format:
# Xcoord Ycoord Zcoord
1 2 1
2 1 1
3 1 1
3 2 2
3 3 3
And in my C++ file, I do:
#include "gnuplot.h"
#include <iostream>
using namespace std;
int main() {
Gnuplot plot;
plot("set border 4095");
plot("splot \"C:/\\Users/\\lRaulMN/\\Desktop/\\Datafile.dat\" with lines");
return 0;
}
This works perfectly and I get this:
Now the question is: Given the 5 points I'm using, is there any way to splot those numbers without having to create the Datafile.dat?
Because in the future, I'll have something like this in my code:
#include "gnuplot.h"
#include <iostream>
#include <vector>
using namespace std;
typedef struct {
double Time;
double X;
double Y;
double Z;
} DimensionalPoint;
int main() {
Gnuplot plot;
plot("set border 4095");
vector<DimensionalPoint> test;
plot("splot \"C:/\\Users/\\lRaulMN/\\Desktop/\\Datafile.dat\" with lines");
return 0;
}
So my idea was to fill the test vector with numbers (Calculate them in my c++ code) and then call splot somehow and represent those numbers.
The first idea that came to mind was to create a file with the numbers (in c++ project, while executing), then make "splot" to that file however I'd be creating a lot of files for each interaction (because I'll have several vectors) and I don't want to end up using this solution.
I guess there won't be a super easy way to insert a vector of 3D points into gnuplot, but I can deal with that as soon as I know how to "splot" at least two numbers with X,Y and Z coordinates.