If you are willing to do some programming, you can write your own function to create the legend, as below:
#lang racket
(require plot pict racket/draw)
;; I could not find how to draw styled lines in pict, so I wrote my own
;; function....
(define (hline1 w h color style)
(define (draw dc x y)
(define pen (send the-pen-list find-or-create-pen color h style))
(define old-pen (send dc get-pen))
(send dc set-pen pen)
(send dc draw-line x (+ y (/ h 2)) (+ x w) (+ y (/ h 2)))
(send dc set-pen old-pen))
(dc draw w h))
(define (legend)
(define picts
(list
(hline1 30 2 "red" 'long-dash) (text "sin")
(hline1 30 4 "blue" 'short-dash) (text "cos")))
(frame
(inset
(vc-append
15
(text "Legend" 'default 14)
(table 2 picts cc-superimpose cc-superimpose 10 10))
5)))
(define (the-plot)
(plot-pict (list
(function sin #:color "red" #:width 2 #:style 'long-dash)
(function cos #:color "blue" #:width 4 #:style 'short-dash))
#:x-min -5 #:x-max 5))
(ht-append (legend) (the-plot))
Which produces:
You can than write the pict to a bitmap using `pict->bitmap`. The code above will not produce interactive plot snips -- it is possible to do that as well, in my own application I have a floating legend that I can drag around the plot so I can see what is underneath it, but implementing that is a bit more complex.
The obvious disadvantage of this code is that you have to manually manage the legend entries or write higher level wrappers for the plot functions to generate both legend entries and plot renderers. The big advantage is that you can style the legend however you want.
Best Regards,
Alex.