import grafica.*;
This code bellow is about making a graph from, loading a csv file.My only problem is that i can not numerate the x axis, as you see in the picture of my graph bellow.But my y axis was numerated automatically.
import grafica.*;
GPlot plot;
Table table;
void setup() {
size(800, 410);
table = loadTable("data.csv", "header");
table.setColumnType("time", Table.FLOAT);
table.setColumnType("ECG", Table.FLOAT);
GPointsArray points = new GPointsArray();
float[] pointSizes = new float[table.getRowCount()];
for (int row = 0; row < table.getRowCount(); row++) {
Float time = table.getFloat(row,"time");
Float ECG = table.getFloat(row,"ECG");
points.add(time,ECG);
pointSizes[row] =5;
}
plot = new GPlot(this);
plot.setPos(0, 0);
plot.setDim(700, 300);
plot.setMar(60, 70, 40, 70);
plot.getXAxis().setNTicks(0);
plot.setPoints(points);
plot.setPointColor(color(100, 100, 255, 50));
plot.setPointSizes(pointSizes);
plot.getYAxis().setAxisLabelText("ECG");
plot.getXAxis().setAxisLabelText("Time");
plot.setAxesOffset(1);
plot.setTicksLength(1);
}
void draw() {
background(255);
// Draw the plot
plot.beginDraw();
//plot.defaultDraw();
plot.drawBackground();
plot.drawBox();
plot.drawXAxis();
plot.drawYAxis();
plot.drawTopAxis();
plot.drawRightAxis();
plot.drawTitle();
plot.drawPoints();
plot.drawLines();
plot.drawGridLines(GPlot.BOTH);
plot.drawLines();
plot.drawLabels();
//plot.drawGridLines(GPlot.VERTICAL);
//plot.drawFilledContours(GPlot.HORIZONTAL, 0);
plot.endDraw();
}
