So I have a code that draws a graph using GPlot functions. I am trying to create a function that changes the points on the graph, so I’m looking for a function to clear the previous points. I tried Plot1.clear(), but it doesn’t even exist. Please, does anyone have a solution?
Thanks
Hi
Inorder to get help from others here it’s more helpful to post your code and you didn’t mention that you need grafica library
To remove layers from the plot you can use plot.removeLayer(“layerId”). If you just want to update all the points in a layer you can use plot.getLayer(“layerId”).setPoints(points). If the points array is empty, this will clean the layer.
Have fun with the library!
Thanks but how do I implement the layer Id?
Here is my code below:
void setup() {
size(2000,1300);
loadData();
getEng_Dspl();
getNoCylinders();
getCarNames();
getHorsepower();
getVeh_Wgh();
getAcc_Time();
getModel_Year();
getCar_Orgn();
getCarMpg();
plot1 = new GPlot(this);
plot1.setPos(0, 0);
plot1.setDim(1500, 1000);
plot1.getTitle().setText(“MAP A”);
plot1.getXAxis().getAxisLabel().setText(“Vehicle Weight (lbs)”);
plot1.getYAxis().getAxisLabel().setText(“Acceleration time 0 to 60 (Sec)”);
plot1.setPointColor(color(0, 0, 0, 255));
plot1.setPointSize(10);
drawScatterPlot1();
void draw() {
plot1.beginDraw();
plot1.drawBackground();
plot1.drawBox();
plot1.drawXAxis();
plot1.drawYAxis();
plot1.drawTitle();
plot1.drawGridLines(GPlot.BOTH);
plot1.drawPoints();
plot1.endDraw();
}
thanks will give it a try