Creating a graph - Error: Graph is bunched together

Hello! I’m recently new to java-processing, and we’re curently working on creating graphs. My program loads, but it bunches my graph up together.

If anyone could help me it would be greatly appreciated!

int[] Private;
int [] Public;
int [] PuPercentage;
int [] PriPercentage;
String [] Dates;
float X, Y, Z1, Z2;
int minTuition, maxTuition; 
PFont nameFont,labelFont;

int value = 0;//for displaying graphs
void setup(){
  size (500,500);
  background (225);
 X = 50; 
  Y = 50;
  Z2 = width - 20; 
  Z2 = height - Z1;
 
 String[] lines = loadStrings ("USNews_Univ_Tuition-2.txt");
 Public = new int[lines.length];
 PuPercentage = new int[lines.length];
 Private = new int[lines.length];
 PriPercentage = new int[lines.length];
 Dates = new String[lines.length];
 
  for (int i=0; i<lines.length; i++) {
    String[] pieces = split(lines[i], ",");

   // 1st value
    Public[i] = int(pieces[0]);
   // 2nd value
    PuPercentage[i] = int(pieces[1]);
    // 3rd value
    Private[i] = int(pieces[2]);
    //4th value
    PriPercentage[i] = int(pieces[3]);
    //5th value
    Dates [i] = (pieces[4]);
  }
  }
  void draw(){
     if (value == 0) {

       PublicvsPrivate();
   } 
  }
   void PublicvsPrivate (){
     rectMode(CENTER);
background(225);                            //Set background Color       
    rectMode(CORNERS);
    noStroke();
    fill(#CCCCCC);
    rect(X, Y, Z1, Z2);
    
//define the color and font that will display numbers 1-20 on the bottom of the graph    
    fill(255);
    stroke(0);
    textAlign(CENTER);
    
//creates numbers and lines that are determined by the length of the array SPD
  for (int i=0; i<Dates.length; i++) {
    float xText = map(i, 0, Public.length, X, Z1);
    text(i, xText, Z2+10);
    strokeWeight(0.5);
    line(xText, Z2, xText, Y);

  }
//Define the color of the line graph and define var. x, and y.
    noFill();
    stroke(0);
    float x=0;
    float y=0;
//use the SPD array to plot points which creates a line graph. Also draws circles at each point.    
    beginShape();    
  for (int i=0; i < Dates.length; i++) {
    x = map(i, 0, Dates.length-1, X, Z1);
    y = map(Public[i], X, Z1, Z2, Y);
    vertex(x, y);
    fill(#22e22b);
    ellipse(x,y,5,5);
//if the mouse dist is less than 10px away from a point, use the date[] to call the date of that specif point.     
    if(dist(x,y,mouseX,mouseY) < 10){
    fill(0);
    textAlign(CENTER);
    text(Dates[i] + "\n" + Dates[i],x,y-20);
  }
  noFill();
  }
  endShape();
  
//lines and numbers off to the right of the graph. 
  fill(255);
  textAlign(RIGHT,CENTER);
  stroke(255);
  for (float i=0; i < 470; i += 50) {
    float yText = map(i, 0, 450, Z2, Y);
    text(i, X-10, yText);
    line(X, yText, X-5, yText);
  }
//Title
fill(#53dddb);
textAlign(CENTER);
text("Public vs Private Tuition Growth in the Last 20 Years", width/2, 50);

}
     

  void mouseClicked() {
  value++;
  if (value > 2) {
      value = 0;
  }
}

With regards to your post (and future posts you make):
Could you describe the problem you are having in more detail – what do you want it to look like v.s. what it does it look like now. Is it an error message or does it just not display the graph how you want it to?

Also, could you either shorten the code to only the relevant bits or provide us with the “USNews_Univ_Tuition-2.txt” file so that we can run the program.

However, I would guess that the problem is in this line:
float xText = map(i, 0, Public.length, X, Z1);
as the value of Z1 is never set so it is assumed to be 0.

I think on this line:
Z2 = width - 20;
you meant to write Z1.