Hi there. I was given the advice to use noloop() to keep my interactive visual from re-drawing over and over. But I have a drop-down list that not doesn't work. if I get rid of the noloop() command the drop down list works but the interactive visual doesn't work right anymore (data constantly being redrawn, and selected data only appearing for a split second). Can anyone help me? Thanks! Kevin PS - I removed some code below because it apparently was too long to post.
Hi. I've been having some trouble with this and hoping for some help. Here's my situation:
I have a .txt file with data organized in lots of columns (30+) and lots of rows (150+). I am using the following commands to parse the data:
lines = loadStrings("datafile.txt");
then later:
for (int i=2; i<lines.length; i++) { // I start with 2 rather than 0 because there are 2 rows of header info in the file
String[] pieces = split(lines[i], '\t'); // parsing each piece of data across the row
float X = float(pieces[5]); // defining a variable called X for column #5
float Y = float(pieces[8]); // defining a variable called Y for column #8
This works fine but I get (and display) the data in the order that it happens to be in the file. I want to sort the data in column 5 in descending order. And then later sort the data in column 8 in descending order.
How do I do this? I've looked up past posts on the sort() function but can't seem to get it to work.
I decided to not post my code because the code is very long and complicated and I am trying to simplify the challenge above.
Hi. I'm trying to do something fairly simply: a XY scatter plot of data. The data is appearing properly but I have 2 questions:
1. any way to make the data appear faster? It takes a while for it all to appear
2. ultimately I want the user to be able to select a team (team affiliation is one of the data elements) and see the plot points associated with that team appear in a different color. I inserted a statement (line 28) as a test - to see if all data points associated with the team "BOS" would appear a different color - but it didn't work.
Any help would be appreciated! Thanks!
Kevin
String [] lines;
int index = 0;
int T = 2; //cell location in data file for team
int N = 1; //cell location in data file for name
int A = 3; //cell location in data file for age
int W = 5; //cell location in data file for WAR
int ColorR;
int ColorG;
int ColorB;
void setup() {
size(1280, 760);
PFont font = loadFont("HelveticaNeue-Light-20.vlw");
Hi there. I've put up a sketch live but there's a gray border around it in the browser. Any ideas on how to make this gray border go away? I'd love to have the entire webpage be black.
Hi there. Thanks to the folks who've coached me in creating the code below. This is a program that creates some visuals based on several .txt files. I'm also using the ControlP5 library for help with drop-down menus. Everything is working great but the applet doesn't work when I try to run it from my browser. I know - based on the error message I get in the java console - that the issue is that I'm not declaring the code public. I've tried several times to do this, and have tried to read past posts to figure out how to do this, but still to no avail. Would someone mind looking at my code and help me figure out which lines need to be declared public and how to do this? Also, can someone provide me with a simple explanation of what declaring code as public means (ie. why for libraries, what's the rationale, etc)? Thanks a lot! Kevin
import controlP5.*;
public ControlP5 cp5;
String currentTeam = "";
String listName = "";
void setup() {
size(1280, 800);
// PFont font = loadFont("CenturyGothic-20.vlw");
PFont font = loadFont("HelveticaNeue-Light-20.vlw");
textFont(font);
linesALSP = loadStrings("ALrankometerSP.txt"); // parsing data from external file (column [0] is list of names, column [1] is ranks, column [2] is abbreviated team name)
linesALRP = loadStrings("ALrankometerRP.txt"); // parsing data from external file (column [0] is list of names, column [1] is ranks, column [2] is abbreviated team name)
linesNLSP = loadStrings("NLrankometerSP.txt"); // parsing data from external file (column [0] is list of names, column [1] is ranks, column [2] is abbreviated team name)
linesNLRP = loadStrings("NLrankometerRP.txt"); // parsing data from external file (column [0] is list of names, column [1] is ranks, column [2] is abbreviated team name)
Hi. Noob here. I've been able to learn how to create some data visualizations which pull from a .txt file (which has a bunch of names with associated data). Right now the user needs to enter the name and hope it matches a name in the .txt file. What I'd prefer to do is have a drop down menu of all the names (pulling from the .txt file) and have the user select a name. 2 questions:
1. Is there a library for this? If so can you recommend a simple one? I looked around and saw some - like ControlP5 - but was a bit overwhelmed by it and wondered if it was overkill for what I am looking for. Also I wasn't sure it had a drop down menu.
2. I'm not 100% sure how libraries work: is it as simple as copying the code from the library into my sketch? I've been looking through the instructions for ControlP5 but still wasn't 100% sure how to use it in my sketch.
Hi. I've got a .xtx file with a column of numbers ranging from 0-4. I'm trying to visualize this data like a barcode image, with each line stroke corresponding to the value in the .txt file. So, for example, a value of 0 would be blank, a value of 1 would be a thin line, a value of 2 a thicker line, etc. But the code doesn't work. I'm using code such as:
String lines[] = loadStrings("batcode.txt"); // to access the column of data in the file
for(int j=1; j<70; j++){ // to index through the 70 rows of data
data = int(split(lines[0], ',' )); // creating an integer variable called data for each row of data
strokeWeight(data[j]); // assigning the variable to each line's stroke
line (50+j*10,100,50+j*10,300); // and then drawing the lines vertically and spaced equally across the screen
When I run it I get a blank gray screen and an error message that says:
The file "batcode.txt" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
Exception in thread "Animation Thread" java.lang.NullPointerException
at Batcode.draw(Batcode.java:59)
at processing.core.PApplet.handleDraw(PApplet.java:1631)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
Here's the code in its entirety: Any idea what I'm doing wrong? Thanks!!!!!
int[] data;
void setup() {
size(1280,800);
PFont font;
font = loadFont("CenturyGothic-20.vlw");
textFont(font);
}
String lines[] = loadStrings("batcode.txt");
void draw() {
background (r240,235,235);
for(int j=1; j<70; j++){
//for(int j=0; j<data.length; j++){ // I thought perhaps I could use this instead of specifying 70 rows but wasn't sure and kept it out.
I'm new to Processing and via experimentation and reading tutorials / posts, I've figured out how to do the following:
- import data from a .txt file
- arrange and display the data in 5 columns, 14 rows
- create a grid of gray boxes behind the text (same 5x14 arrangement)
What I'd really like to do next is use the gray boxes a bit more intelligently. I'd like to:
- Define a variable at the beginning of the program that identifies a single team - say Boston (shown as BOS)
- For each column, only draw the gray box for the player that plays for BOS and all the players below him in the column
The goal is to show how Boston pitchers rank compared to the rest of the league, with each column representing a quartile of pitchers. So each column would show (via the height of the gray boxes) how well ranked each Boston pitcher is). Sort of like a graphic equalizer. I tried to create some logic within the loop to do this, but got nowhere (a bit too advanced for me and I spun my wheels for a long time).
Can someone look at my code and help me figure out how to do this? Thanks a ton! Kevin
CODE BELOW:
// misc setup
void setup() {
size(1280,800);
PFont font;
font = loadFont("CenturyGothic-20.vlw");
textFont(font);
}
// color settings
// background color
int r1=240;int g1=235;int b1=235;
// highlighted color
int r2=165;int g2=165;int b2=165;
//text color
int r3=250;int g3=250;int b3=250;
void draw() {
background (r1,g1,b1); //gray
// parsing data from external file (column [0] is list of names, column [1] is ranks, column [2] is abbreviated team name)
Hi. I'm new to processing and need some help. I've got a csv file that contains both text and numbers. The data file looks something like this:
Column A Column B
Jones 7
Smith 10
Harrison 3
I'd like my program to be able to import this data and use it to do things like:
- use the numbers in column B to rank order the people
- print the people's names in rank order
So I'd want my program to generate (and display on screen when run) the following:
Smith 10
Jones 7
Harrison 3
I've been looking around at different tutorials and posts, trying to understand things like loadstrings, but can't seem to figure this out. Can anyone help me out with some advice or even better some code?