Labelling at an angle
in
Contributed Library Questions
•
1 year ago
Hi, I am trying to get my x-axis labels slanting at a seventy-ish degree angle. I have tried putting a rotate(PI/3.0); line in to no avail so far. I use Fry's table.pde on a separate tab, though I don't think this needs to be shown. Any help gratefully appreciated. Here is my sketch:
import org.gicentre.utils.stat.*; // For chart classes.[8]
//sketch-wide variables
Table table; //[1]
BarChart barChart; //[2]
float[] boroughs, homeless; //[10]
PFont titleFont, smallFont; //fonts
//initialisation
void setup ()
{
size(800, 400);
smooth();
titleFont = loadFont("Calibri-24.vlw");
smallFont = loadFont("Calibri-24.vlw");
textFont(smallFont);
barChart = new BarChart(this); //[3]
readData(); //[4]
boroughs = new float[table.getRowCount()];
homeless = new float[table.getRowCount()];
for (int row=0; row<table.getRowCount(); row++)
{
boroughs[row] = table.getFloatAt(row, 0);
homeless[row] = table.getFloatAt(row, 10);
}
barChart.setData(homeless); //[9]
barChart.setBarLabels(new String[] {"Bromley","Richmond upon Thames","Hillingdon","Havering","Kingston upon Thames","Sutton","Hounslow",
"Merton","Wandsworth","Croydon","Lambeth","Southwark","Lewisham","Greenwich",
"Ealing","Hammersmith and Fulham","Brent","Harrow", "Barnet", "Islington", "Hackney", "Newham",
"Barking and Dagenham", "Haringey", "Enfield", "Waltham Forest", "Redbridge", "Bexley", "Kensington and Chelsea",
"Westminster", "Camden", "Tower Hamlets", "City of London"});
barChart.showValueAxis(true);
barChart.showCategoryAxis(true);
}
//processing draw
void draw()
{
background(255);
barChart.draw(20, 10, width, height/1.5); //[16]
fill(0);
textFont(titleFont);
text("Number Homeless per 1,000 Households", 70, 30);
}
parse tab:
void readData()
{
// load data from table
table = new Table("londonHousing1.tsv");
}
import org.gicentre.utils.stat.*; // For chart classes.[8]
//sketch-wide variables
Table table; //[1]
BarChart barChart; //[2]
float[] boroughs, homeless; //[10]
PFont titleFont, smallFont; //fonts
//initialisation
void setup ()
{
size(800, 400);
smooth();
titleFont = loadFont("Calibri-24.vlw");
smallFont = loadFont("Calibri-24.vlw");
textFont(smallFont);
barChart = new BarChart(this); //[3]
readData(); //[4]
boroughs = new float[table.getRowCount()];
homeless = new float[table.getRowCount()];
for (int row=0; row<table.getRowCount(); row++)
{
boroughs[row] = table.getFloatAt(row, 0);
homeless[row] = table.getFloatAt(row, 10);
}
barChart.setData(homeless); //[9]
barChart.setBarLabels(new String[] {"Bromley","Richmond upon Thames","Hillingdon","Havering","Kingston upon Thames","Sutton","Hounslow",
"Merton","Wandsworth","Croydon","Lambeth","Southwark","Lewisham","Greenwich",
"Ealing","Hammersmith and Fulham","Brent","Harrow", "Barnet", "Islington", "Hackney", "Newham",
"Barking and Dagenham", "Haringey", "Enfield", "Waltham Forest", "Redbridge", "Bexley", "Kensington and Chelsea",
"Westminster", "Camden", "Tower Hamlets", "City of London"});
barChart.showValueAxis(true);
barChart.showCategoryAxis(true);
}
//processing draw
void draw()
{
background(255);
barChart.draw(20, 10, width, height/1.5); //[16]
fill(0);
textFont(titleFont);
text("Number Homeless per 1,000 Households", 70, 30);
}
parse tab:
void readData()
{
// load data from table
table = new Table("londonHousing1.tsv");
}
1