Re: [racket-users] Re: Plot ticks with arbitrary strings - breaks DrRacket

2016-10-15 Thread Laurent
Ah, thanks Alex, that helps!

Actually, the problem was slightly more complex than that.
First, note that your fix should use the value of the pretick rather than
the position in the list of preticks.
Now, I logged the values of the preticks that plot was generating, and it
looked something like this:
(#(struct:pre-tick 1 #t) #(struct:pre-tick
7426988859172397/4503599627370496 #t) #(struct:pre-tick 2 #t)
#(struct:pre-tick 3 #t))

which means I get some non-integer rationals sometimes.
So the proper fix is (I believe):
(for/list ([t pre-ticks])
 (define idx (pre-tick-value t))
 (if (and (exact-nonnegative-integer? idx)
 (< idx N))
   (list-ref string-list idx)
   ""))

One last problem that may remain is that in my logs sometimes some integers
values are skipped, but this doesn't seem to appear on the screen, so maybe
these are just temporary values.

Thanks!
Laurent

On Sat, Oct 15, 2016 at 12:31 AM, Alex Harsanyi 
wrote:

> Your tick format function returns less labels than the number of items in
> the pre-ticks.  It should return one label for each pre-tick object (I just
> printed out the lengths from the function to find this out.)
>
> To fix this, I replaced the format function with
>
>  (for/list (((t idx) (in-indexed pre-ticks)))
>(list-ref string-list idx))
>
> Alex.
>
> On Friday, October 14, 2016 at 5:28:08 PM UTC+8, Laurent Orseau wrote:
> > Hi all,
> >
> >
> > I'm trying to write a `string-ticks` function to have arbitrary strings
> on the (y) axis.
> > It mostly works, but as soon as I try to zoom by selecting a rectangle
> *that touches upper left corner of the plot frame* DrRacket's interaction
> window goes crazy and I have to restart it.
> >
> >
> > Here's the (faulty) code:https://gist.github.com/Metaxal/
> e4ac303d442cbf9fb7f3edc21d8a9019
> >
> >
> >
> > Anyone has an idea about what goes wrong here?
> >
> >
> > Thanks,
> > Laurent
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Plot ticks with arbitrary strings - breaks DrRacket

2016-10-14 Thread Alex Harsanyi
On Saturday, October 15, 2016 at 9:19:20 AM UTC+8, Robby Findler wrote:
> Is there a contract we could add somewhere?

Well, the contract should be that the number of elements in the output list 
should be the same as the number of elements in the input list.  I'm not sure 
how that would be expressed.

However, the separation of the layout and format functions in the ticks 
structure seems odd to me.  There could have been a single function that would 
generate tick objects with a value and a label, with the label being #f for 
minor ticks.

Alex.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Plot ticks with arbitrary strings - breaks DrRacket

2016-10-14 Thread Robby Findler
Is there a contract we could add somewhere?

Robby

On Fri, Oct 14, 2016 at 6:31 PM, Alex Harsanyi  wrote:
> Your tick format function returns less labels than the number of items in the 
> pre-ticks.  It should return one label for each pre-tick object (I just 
> printed out the lengths from the function to find this out.)
>
> To fix this, I replaced the format function with
>
>  (for/list (((t idx) (in-indexed pre-ticks)))
>(list-ref string-list idx))
>
> Alex.
>
> On Friday, October 14, 2016 at 5:28:08 PM UTC+8, Laurent Orseau wrote:
>> Hi all,
>>
>>
>> I'm trying to write a `string-ticks` function to have arbitrary strings on 
>> the (y) axis.
>> It mostly works, but as soon as I try to zoom by selecting a rectangle *that 
>> touches upper left corner of the plot frame* DrRacket's interaction window 
>> goes crazy and I have to restart it.
>>
>>
>> Here's the (faulty) 
>> code:https://gist.github.com/Metaxal/e4ac303d442cbf9fb7f3edc21d8a9019
>>
>>
>>
>> Anyone has an idea about what goes wrong here?
>>
>>
>> Thanks,
>> Laurent
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.