2012-08-28 26 views
2

這是來自shell腳本(來自Hannon Lab)的gnuplot命令,我想使用rgplot gem將繪圖部分移植到Ruby,但是我無法獲得正確的語法。這個gnuplot代碼的正確的Ruby gnuplot(rgplot)語法是什麼?

set boxwidth 0.75 absolute 
set size 1,1 
set style fill solid 1.00 border -1 
set xlabel \"read position\" 
set title \"Nucleotides distribution $TITLE\" 
set ylabel \"% of total (per read position)\" 
set key outside right top vertical Left reverse enhanced autotitles columnhead nobox 
set key invert samplen 4 spacing 1 width 0 height 0 
set style histogram rowstacked 
set style data histograms 
set noytics 
set xtics 1 
set yrange [ 0.00000 : 100.000 ] noreverse nowriteback 

plot '$FILENAME' using (100.*column(13)/column(18)):xtic(1) title \"A\" lt rgb \"#5050ff\", \ 
     '' using (100.*column(14)/column(18)) title \"C\" lt rgb \"#e00000\", \ 
     '' using (100.*column(15)/column(18)) title \"G\" lt rgb \"#00c000\", \ 
     '' using (100.*column(16)/column(18)) title \"T\" lt rgb \"#e6e600\", \ 
     '' using (100.*column(17)/column(18)) title \"N\" lt rgb \"pink\" 
" 

到目前爲止,我有這樣的:

Gnuplot.open do |gp| 
    Gnuplot::Plot.new(gp) do |plot| 
    plot.terminal options[:terminal] 
    plot.title options[:title] 
    plot.xlabel options[:xlabel] 
    plot.ylabel options[:ylabel] 
    plot.output options[:data_out] if options[:data_out] 
    plot.boxwidth "0.75 absolute" 
    plot.size  "1,1" 
    plot.yrange "[0:100]" 
    plot.noytics 
    plot.xtics 1 
    plot.key  "outside right top vertical Left reverse enhanced autotitles columnhead nobox" 
    plot.key  "invert samplen 4 spacing 1 width 0 height 0" 
    plot.style "fill solid 1.00 border -1" 
    plot.style "histogram rowstacked" 
    plot.style "data histograms" 

    plot.data << Gnuplot::DataSet.new([x, a]) do |ds| 
     ds.title = "A" 
    end 
    end 
end 

,但我需要幫助得到它的權利......

回答

4

我終於緩過勁來:

Gnuplot.open do |gp| 
    Gnuplot::Plot.new(gp) do |plot| 
    plot.terminal options[:terminal] 
    plot.title options[:title] 
    plot.xlabel options[:xlabel] 
    plot.ylabel options[:ylabel] 
    plot.output options[:data_out] if options[:data_out] 
    plot.ytics "out" 
    plot.xtics "out" 
    plot.yrange "[0:100]" 
    plot.xrange "[0:#{max_len}]" 
    plot.auto  "fix" 
    plot.offsets "1" 
    plot.key  "outside right top vertical Left reverse enhanced autotitles columnhead nobox" 
    plot.key  "invert samplen 4 spacing 1 width 0 height 0" 
    plot.style "fill solid 0.5 border" 
    plot.style "histogram rowstacked" 
    plot.style "data histograms" 
    plot.boxwidth "0.75 absolute" 

    plot.data << Gnuplot::DataSet.new(n) do |ds| 
     ds.using = "1" 
     ds.with = "histogram lt rgb \"black\"" 
     ds.title = "N" 
    end 

    plot.data << Gnuplot::DataSet.new(g) do |ds| 
     ds.using = "1" 
     ds.with = "histogram lt rgb \"yellow\"" 
     ds.title = "G" 
    end 

    plot.data << Gnuplot::DataSet.new(c) do |ds| 
     ds.using = "1" 
     ds.with = "histogram lt rgb \"blue\"" 
     ds.title = "C" 
    end 

    plot.data << Gnuplot::DataSet.new(t) do |ds| 
     ds.using = "1" 
     ds.with = "histogram lt rgb \"green\"" 
     ds.title = "T" 
    end 

    plot.data << Gnuplot::DataSet.new(a) do |ds| 
     ds.using = "1" 
     ds.with = "histogram lt rgb \"red\"" 
     ds.title = "A" 
    end 
    end 
end 
相關問題