var sketch = function (p) {
// Initial setup
p.setup = function () {
// Create the canvas
var canvas = p.createCanvas(500, 350);
p.background(150);
// Prepare the points for the plot
var points = [];
var seed = 100 * p.random();
for (var i = 0; i < 100; i++) {
points[i] = new GPoint(i, 10 * p.noise(0.1 * i + seed));
}
// Create a new plot and set its position on the screen
var plot = new GPlot(p);
plot.setPos(25, 25);
// Set the plot title and the axis labels
plot.setPoints(points);
plot.getXAxis().setAxisLabelText("x axis");
plot.getYAxis().setAxisLabelText("y axis");
plot.setTitleText("A very simple example");
// Draw it!
plot.defaultDraw();
p.noLoop();
};
};
var myp5 = new p5(sketch);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.