Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

plotting String on a graph  RSS feed

 
Julian Mishke
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


I'm trying to plot a String of names on a graph using a .tsv file, but I'm having a problem with my for loop.

I first plotted the numbers- each number refers to the city (col 0)- this is the code.




Now, I would like to replace the numbers with the names of the places (column 5) but having trouble with getting the code right. Would you please, let me know where I'm going wrong?
Thank you!




This is the data file:


 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... error msg: 'the function getString(int,int) does not exist' ...

This error message is telling you that the object referenced by "data" does not have a method called getString that takes two ints. What type of object is "data"?
 
Julian Mishke
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marc,

The .txt file I'm plotting data from is called data (sample attached below).

Would it be easier for you if you saw the full code? I attached it to this post. The bit I'm struggling with is 'void drawBoroughsNames()' (line no 122-132).

I am very grateful for your help and apologies for double posting.

J.





 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like "data" is something called a FloatTable, and that's what should contain the method, getString(int a, int b). Do you have a class definition for this?
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that Java doesn't have functions. It has methods.
 
Campbell Ritchie
Marshal
Posts: 55715
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch
 
Julian Mishke
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone and big thank you for very warm welcome.

Thanks Mark for suggestion about definition of the method 'getString'- I added another class called 'Table' which has this method defined. It doesn't error the method now at least.

Now, going back to the original question, I am still struggling with getting my for loop working ('void drawBoroughsNames()'). I guess this bit relates to it:



I added println and it doesn't show anything, apart from new error: 'The field Component.x is not visible'. ???
Just to remind you- I'm trying to replace the numbers printed on the x-axis with the names of the places.

Thanks a lot for all your help!
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you define x in drawBoroughsNames()?
 
Julian Mishke
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Wouter, that was very helpful suggestion. I managed to plot the names, but now, the problem is- not all the names from the rows are being displayed- it skipped the last name. I don't understand why as all the numbers were showing on the x-axis.

Would you please let me know where I'm going wrong with this?

Thanks a lot.

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!