* guile: some update for the output format
This commit is contained in:
@ -45,24 +45,29 @@ not found."
|
||||
(if (access? progpath X_OK) ;; is
|
||||
progpath
|
||||
#f))))
|
||||
2
|
||||
(define* (mu:plot-histogram data title x-label y-label #:optional (text-only #f) (extra-gnuplot-opts '()))
|
||||
"Plot DATA with TITLE, X-LABEL and X-LABEL. If TEXT-ONLY is true,
|
||||
display using raw text, otherwise, use a graphical window. DATA is a
|
||||
list of cons-pairs (X . Y)."
|
||||
|
||||
(define* (mu:plot-histogram data title x-label y-label output
|
||||
#:optional (extra-gnuplot-opts '()))
|
||||
"Plot DATA with TITLE, X-LABEL and X-LABEL using the gnuplot
|
||||
program. DATA is a list of cons-pairs (X . Y). OUTPUT is a string
|
||||
that determines the type of output that gnuplot produces, depending on
|
||||
the system. Which options are available depends on the particulars for
|
||||
the gnuplot installation, but typical examples would be \"dumb\" for
|
||||
text-only display, \"wxterm\" to write to a graphical window, or
|
||||
\"png\" to write a PNG-image to stdout. EXTRA-GNUPLOT-OPTS are any
|
||||
additional options for gnuplot."
|
||||
(if (not (find-program-in-path "gnuplot"))
|
||||
(error "cannot find 'gnuplot' in path"))
|
||||
|
||||
(let ((datafile (export-pairs data))
|
||||
(gnuplot (open-pipe "gnuplot -p" OPEN_WRITE)))
|
||||
(display (string-append
|
||||
"reset\n"
|
||||
"set term " (if text-only "dumb" "wxt") "\n"
|
||||
"set term " (or output "dumb") "\n"
|
||||
"set title \"" title "\"\n"
|
||||
"set xlabel \"" x-label "\"\n"
|
||||
"set ylabel \"" y-label "\"\n"
|
||||
"set boxwidth 0.9\n"
|
||||
(string-join extra-gnuplot-opts "\n")
|
||||
(string-join extra-gnuplot-opts "\n")
|
||||
"plot \"" datafile "\" using 2:xticlabels(1) with boxes fs solid\n")
|
||||
gnuplot)
|
||||
(close-pipe gnuplot)))
|
||||
|
||||
Reference in New Issue
Block a user