exprociacion graf 2D

This commit is contained in:
abe- 2017-06-18 00:49:49 +02:00
parent 611fc46561
commit 1e5247cdc8
2 changed files with 71 additions and 7 deletions

View file

@ -0,0 +1,64 @@
var exceso, reserva, exceptuadas;
var nombres;
var plot;
function setup() {
createCanvas(800,519);
nombres = new Array("Norte","Duero","Ebro","Pirineo","Jucar","Tajo","Guadiana","Guadalquivir","Sur", "Segura", "Islas");
exceso = new Array(15267,35628,136465,3466,19615,64179,81809,148193,13326,35075,3235);
reserva = new Array(12251,62730,131128,24433,54545,68854,82052,140453,20980,131042,5985);
exceptuadas = new Array(7094,31194,128457,3289,15734,39460,21419,68830,23782,68386,15675);
var pointSizes = [];
var points = [];
for (var n = 0; n < nombres.length; n++) {
points[n] = new GPoint(exceso[n], exceptuadas[n], nombres[n]);
pointSizes[n] = map(reserva[n],5000,141000,5,100);
}
// Creamos el plot
plot = new GPlot(this);
plot.setDim(width-230, height-100);
plot.setTitleText("Tierras en exceso, reserva y exceptuadas por cuenca hidrografica segun PGC");
plot.getXAxis().setAxisLabelText("Tierras en exceso (Has)");
plot.getYAxis().setAxisLabelText("Tierras exceptuadas (Has)");
plot.setPoints(points);
plot.setPointSizes(pointSizes);
plot.setPointColor(color(255,0,0,50));
plot.setLineColor(color(0));
plot.setLabelBgColor(color(255,0));
}
function draw() {
background(255);
// Draw the plot
plot.beginDraw();
plot.drawBox();
plot.drawXAxis();
plot.drawYAxis();
plot.drawTitle();
plot.drawGridLines(GPlot.BOTH);
plot.drawPoints();
plot.drawLabels();
plot.drawAllLabels();
plot.endDraw();
textFont("Helvetica");
textSize(11);
fill(0);
textAlign(LEFT);
text("Tierras en reserva (Has)", 660, 330);
textAlign(CENTER);
stroke(100);
noFill();
ellipse(720, 390, 100, 100);
fill(0);
text("140000", 720, 390);
noFill();
ellipse(720, 455, 10, 10);
fill(0);
text("14000", 720, 475);
}

View file

@ -3,7 +3,7 @@ var nombres;
var plot; var plot;
function setup() { function setup() {
createCanvas(800,519); createCanvas(800-130,519);
nombres = new Array("Norte","Duero","Ebro","Pirineo","Jucar","Tajo","Guadiana","Guadalquivir","Sur", "Segura", "Islas"); nombres = new Array("Norte","Duero","Ebro","Pirineo","Jucar","Tajo","Guadiana","Guadalquivir","Sur", "Segura", "Islas");
exceso = new Array(15267,35628,136465,3466,19615,64179,81809,148193,13326,35075,3235); exceso = new Array(15267,35628,136465,3466,19615,64179,81809,148193,13326,35075,3235);
reserva = new Array(12251,62730,131128,24433,54545,68854,82052,140453,20980,131042,5985); reserva = new Array(12251,62730,131128,24433,54545,68854,82052,140453,20980,131042,5985);
@ -13,18 +13,18 @@ function setup() {
var points = []; var points = [];
for (var n = 0; n < nombres.length; n++) { for (var n = 0; n < nombres.length; n++) {
points[n] = new GPoint(exceso[n], exceptuadas[n], nombres[n]); points[n] = new GPoint(exceso[n]+reserva[n], exceptuadas[n], nombres[n]);
pointSizes[n] = map(reserva[n],5000,141000,5,100); pointSizes[n] = map(reserva[n],5000,141000,5,100);
} }
// Creamos el plot // Creamos el plot
plot = new GPlot(this); plot = new GPlot(this);
plot.setDim(width-230, height-100); plot.setDim(width-100, height-100);
plot.setTitleText("Tierras en exceso, reserva y exceptuadas por cuenca hidrografica segun PGC"); plot.setTitleText("Tierras en exceso, reserva y exceptuadas por cuenca hidrografica segun PGC");
plot.getXAxis().setAxisLabelText("Tierras en exceso (Has)"); plot.getXAxis().setAxisLabelText("Tierras en exceso (Has)");
plot.getYAxis().setAxisLabelText("Tierras exceptuadas (Has)"); plot.getYAxis().setAxisLabelText("Tierras en reserva y exceptuadas (Has)");
plot.setPoints(points); plot.setPoints(points);
plot.setPointSizes(pointSizes); //plot.setPointSizes(pointSizes);
plot.setPointColor(color(255,0,0,50)); plot.setPointColor(color(255,0,0,50));
plot.setLineColor(color(0)); plot.setLineColor(color(0));
plot.setLabelBgColor(color(255,0)); plot.setLabelBgColor(color(255,0));
@ -45,7 +45,7 @@ function draw() {
plot.drawLabels(); plot.drawLabels();
plot.drawAllLabels(); plot.drawAllLabels();
plot.endDraw(); plot.endDraw();
/*
textFont("Helvetica"); textFont("Helvetica");
textSize(11); textSize(11);
fill(0); fill(0);
@ -60,5 +60,5 @@ function draw() {
noFill(); noFill();
ellipse(720, 455, 10, 10); ellipse(720, 455, 10, 10);
fill(0); fill(0);
text("14000", 720, 475); text("14000", 720, 475);*/
} }