# Gruff labels

**URL:** <https://www.ruby-forum.com/t/gruff-labels/155028>\
**Category:** Ruby\
**Created:** [December 6, 2008, 3:49pm UTC](https://www.ruby-forum.com/t/gruff-labels/155028 "2008-12-06T15:49:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ukbell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/898d66/32.png) [@ukbell](https://www.ruby-forum.com/u/ukbell)\
**Post date:** [December 6, 2008, 3:49pm UTC](https://www.ruby-forum.com/t/gruff-labels/155028/1 "2008-12-06T15:49:20Z")

</div>

I have been working on this code for a few days and can’t seem to figure  
out what I am doing wrong… Labeling gruff is pretty easy for the most  
part (just put it in hash format) but I can’t get this to work for  
anything…

This is basically the code that I am working on:

I won’t go through the code to get the first input and the last input  
for both the hour and the minute, but I am fine on that part of the code  
and I named them: last\_min\_hour, last\_time\_min, last\_time\_hour and  
first\_time\_min.

count\_incr += 0  
access\_bar\_hash = Hash.new(0)

time\_regex = /d{1,2}:[5][0]/ # looks for only 50 minute intervals

reads = 60 # this will change based on how many times the program runs  
label\_spacing = 60/reads # 60 is how many columns there are

final\_last\_time = [last\_time\_hour, last\_time\_min].join(":")  
final\_first\_time = [first\_time\_hour, first\_time\_min].join(":")

incr\_hash[count\_incr] = final\_first\_time  
while count\_incr \< 8 # the 8 will actually be dynamic, but use this for  
now  
if incr\_hash[count\_incr] =~ time\_regex  
first\_time\_hour += 1  
first\_time\_min = ‘00’  
else  
first\_time\_min = first\_time\_min.to\_i  
first\_time\_min += 10  
end  
count\_incr += 1  
incr\_hash[count\_incr] = [first\_time\_hour, first\_time\_min].join(":")  
spacer = label\_spacing \* (count\_reads)  
access\_bar\_hash[(label\_spacing \* count\_incr)] =  
incr\_hash[count\_incr]  
end

access\_bar.labels = access\_bar\_hash

* * *

What I don’t understand is that if i take the output of what  
access\_bar\_hash gives me, it input that directly into the  
access\_bar.labels, this works perfect. But I must be putting this into  
the hash wrong somehow… Can anyone take a look at this and give me  
some help?

---

<div class="post-metadata">

**Author:** ![ukbell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/898d66/32.png) [@ukbell](https://www.ruby-forum.com/u/ukbell)\
**Post date:** [December 6, 2008, 3:51pm UTC](https://www.ruby-forum.com/t/gruff-labels/155028/2 "2008-12-06T15:51:02Z")

</div>

I said up there that “reads = 60” but actually reads should equal 8 for  
now… That shouldn’t matter too much though.

---

<div class="post-metadata">

**Author:** ![ukbell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/898d66/32.png) [@ukbell](https://www.ruby-forum.com/u/ukbell)\
**Post date:** [December 8, 2008, 7:04am UTC](https://www.ruby-forum.com/t/gruff-labels/155028/3 "2008-12-08T07:04:39Z")

</div>

> reads = 60 # this will change based on how many times the program runs  
> label\_spacing = 60/reads # 60 is how many columns there are

Just guessing, make sure your labels are for “exactly the right x  
locations”–are you trying to label x or y? What happens currently?  
What did you expect to happen instead?  
Thanks!  
-=R

---

<div class="post-metadata">

**Author:** ![ukbell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/898d66/32.png) [@ukbell](https://www.ruby-forum.com/u/ukbell)\
**Post date:** [December 8, 2008, 1:43pm UTC](https://www.ruby-forum.com/t/gruff-labels/155028/4 "2008-12-08T13:43:15Z")

</div>

Rereading through my description above, this isn’t a very good  
description of what I am trying to do… Essentially I am trying to  
dynamically update the x-axis. I am reading in apache’s server every 60  
seconds and storing the data to a csv file. Then in this program, I take  
that csv file and graph the data. And for the labels, I need to print a  
label at every 10 minute interval. So if the program runs from 7:00 to  
8:00, I should have 7:00, 7:10, etc… 8:00.

The error message that I am getting is something about annotation.  
“cannot convert fixnum to string.”

---

<div class="post-metadata">

**Author:** ![ukbell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/898d66/32.png) [@ukbell](https://www.ruby-forum.com/u/ukbell)\
**Post date:** [December 11, 2008, 1:22pm UTC](https://www.ruby-forum.com/t/gruff-labels/155028/5 "2008-12-11T13:22:20Z")

</div>

> The error message that I am getting is something about annotation.  
> “cannot convert fixnum to string.”

Odd  
I’d first make sure you’re passing in something like  
g.labels = {  
0 =\> ‘5/6’,  
2 =\> ‘5/15’,  
4 =\> ‘5/24’,  
6 =\> ‘5/30’,  
}

-=R

---

<div class="post-metadata">

**Author:** ![ukbell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/898d66/32.png) [@ukbell](https://www.ruby-forum.com/u/ukbell)\
**Post date:** [December 11, 2008, 6:19pm UTC](https://www.ruby-forum.com/t/gruff-labels/155028/6 "2008-12-11T18:19:48Z")

</div>

Roger P. wrote:

> > The error message that I am getting is something about annotation.  
> > “cannot convert fixnum to string.”
> 
> Odd  
> I’d first make sure you’re passing in something like  
> g.labels = {  
> 0 =\> ‘5/6’,  
> 2 =\> ‘5/15’,  
> 4 =\> ‘5/24’,  
> 6 =\> ‘5/30’,  
> }
> 
> -=R

It turned out, my problem was that when I initialized my hash, I  
shouldn’t have ended with the (0). I didn’t think it was a big deal but  
it worked perfect as soon as I took it away…

Thanks for your help on the matter though. Much appreciated.
