From jilani.khaldi1 at virgilio.it Thu Apr 6 18:49:46 2006 From: jilani.khaldi1 at virgilio.it (Jilani Khaldi) Date: Fri, 07 Apr 2006 00:49:46 +0200 Subject: [Tioga-users] Getting the PDF from figures.rb Message-ID: <44359B0A.50305@virgilio.it> Hi, I am trying to get the drwaing # figures.rb # I added this line require 'Tioga/FigureMaker' class MyFigures include Tioga include FigureConstants ... list.each { |name| show_marker(name, x, y); y += dy } end end p = MyFigures.new I understood what the code does, but I can't figure out what is the code to add here to get the PDF with the result of the method "curve". Any hint? Thanks! jk -- Jilani KHALDI http://jkhaldi.oltrelinux.com From paxton at kitp.ucsb.edu Fri Apr 7 05:58:42 2006 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Fri, 7 Apr 2006 02:58:42 -0700 Subject: [Tioga-users] Getting the PDF from figures.rb In-Reply-To: <44359B0A.50305@virgilio.it> References: <44359B0A.50305@virgilio.it> Message-ID: <45402EBB-1AE2-4A22-AE3E-D431F12AF641@kitp.ucsb.edu> Hi Jilani, Thanks for the question -- it points out a gap in the tutorial that I'll need to fix! The current tutorial discusses the two ways of using Tioga interactively: by command line (using irb), or by GUI on the Mac (using the Mac application that can be downloaded from my website). But the tutorial doesn't discuss 'batch' use of Tioga which is a natural way to think about plotting if you are coming from something like pgplot, for example. For getting started as a new user, you may now want to go back to the tutorial and reread the first few sections up to the 'Sample' section showing how to use irb as a command line front-end. NOTE: On my Mac running 10.4.5, I for some reason now need to copy the .irbrc file from my home directory to the directory where I'm running irb. I don't know why this is needed or when it started being needed. If someone can show me how to get around this, please let me know! Here's a simple way to do things in a batch-mode. Let's assume we want to get pdfs for 2 of the figures defined in 'figures/samples/ figures.rb'. Do 'cd' to that directory, and make a file called 'fig_batch.rb' with the following lines: require 'Tioga/Tioga' include Tioga load 'figures.rb' $fm = FigureMaker.default $fm.make_preview_pdf('Icon') $fm.make_preview_pdf(2) -------------- next part -------------- A non-text attachment was scrubbed... Name: fig_batch.rb Type: text/x-ruby-script Size: 136 bytes Desc: not available Url : http://rubyforge.org/pipermail/tioga-users/attachments/20060407/bd76582a/attachment.bin -------------- next part -------------- Then enter 'ruby < fig_batch.rb' on the terminal command line to get ruby to execute the file. You should get some terminal output like this: cd figures_out; pdflatex -interaction nonstopmode Icon.tex > pdflatex.log cd figures_out; pdflatex -interaction nonstopmode Curve.tex > pdflatex.log And the folder 'figures_out' should now have a bunch of new files including Icon.pdf and Curve.pdf. For documentation on the 'make_preview_pdf' method and others like it, see the documentation for Tioga::Executive available from the website. Cheers, Bill From jilani.khaldi1 at virgilio.it Fri Apr 7 08:38:55 2006 From: jilani.khaldi1 at virgilio.it (Jilani Khaldi) Date: Fri, 07 Apr 2006 14:38:55 +0200 Subject: [Tioga-users] Getting the PDF from figures.rb In-Reply-To: <45402EBB-1AE2-4A22-AE3E-D431F12AF641@kitp.ucsb.edu> References: <44359B0A.50305@virgilio.it> <45402EBB-1AE2-4A22-AE3E-D431F12AF641@kitp.ucsb.edu> Message-ID: <44365D5F.3000804@virgilio.it> Hi Bill, > > Thanks for the question -- it points out a gap in the tutorial that > I'll need to fix! The current tutorial discusses the two ways of > using Tioga interactively: by command line (using irb), or by GUI on > the Mac (using the Mac application that can be downloaded from my > website). But the tutorial doesn't discuss 'batch' use of Tioga > which is a natural way to think about plotting if you are coming from > something like pgplot, for example. > I fact, I need it batch-mode to generate on-line PDF files. I have been using GLE (http://glx.sourceforge.net/), it is fast and lean but with a propietary language unusable out of GLE context. > Here's a simple way to do things in a batch-mode. Let's assume we > want to get pdfs for 2 of the figures defined in 'figures/samples/ > figures.rb'. Do 'cd' to that directory, and make a file called > 'fig_batch.rb' with the following lines: > > require 'Tioga/Tioga' > include Tioga > > load 'figures.rb' > > $fm = FigureMaker.default > $fm.make_preview_pdf('Icon') > $fm.make_preview_pdf(2) I changed it slightly to get it working on my system (Linux Slackware box): require 'Tioga/FigureMaker' require 'figures.rb' class MyFig < MyFigures def run t.make_preview_pdf('Icon') t.make_preview_pdf(2) end end fm = MyFig.new fm.run Thank you! Jilani -- Jilani KHALDI http://jkhaldi.oltrelinux.com From alexg at kuicr.kyoto-u.ac.jp Wed Apr 26 22:51:18 2006 From: alexg at kuicr.kyoto-u.ac.jp (Alex Gutteridge) Date: Thu, 27 Apr 2006 11:51:18 +0900 Subject: [Tioga-users] Log log plots Message-ID: <62598E7A-A606-451A-A4A4-6EAFD3F724B7@kuicr.kyoto-u.ac.jp> Hi, I'm trying to use Tioga to make a log log plot of some data and I'm having difficulty with the x-axis. I've posted the Ruby code I'm using below (it's in 3 files 'plots.rb', loglogplot.rb' and 'batch.rb'. I run it with the command 'ruby batch.rb data' ('data' is my data file). If I uncomment the dummy data line in loglogplot.rb and set @mids to simple integers it's works fine, but when I use my real data the log scale is broken. The major tick marks become: '1', '10', '10', '10^2', '10^2', '10^3', which is obviously incorrect. I've pasted the real data I'm using below the scripts. I've gzipped my whole working directory and put it here http:// web.kuicr.kyoto-u.ac.jp/~alexg/files/loglog.tar.gz if that's simpler. The broken pdf demonstrating the problem is in the figures directory. Thanks in advance for any help. # plots.rb class TiogaPlot include Math include Tioga include FigureConstants def t @figure_maker end def initialize @figure_maker = FigureMaker.default t.save_dir = 'plots_out' @data_filename = "data/datalog.data" t.auto_refresh_filename = @data_filename t.add_model_number = true @image_right_margin = 0.07 @margin = 0.1 @header = Dvector.new @positions = Dvector.new @have_data = false t.model_number = -1 end def show_model_number(pos = 1, shift = 4) if !(t.in_subplot) && t.model_number > 0 t.show_text('text' => t.model_number.to_s, 'side' => TOP, 'pos' => pos, 'shift' => shift, 'scale' => 0.8, 'justification' => RIGHT_JUSTIFIED) end end def plot_boundaries(xs,ys,margin,ymin=nil,ymax=nil) xmin = xs.min xmax = xs.max ymin = ys.min if ymin == nil ymax = ys.max if ymax == nil width = (xmax == xmin)? 1 : xmax - xmin height = (ymax == ymin)? 1 : ymax - ymin left_boundary = xmin - margin * width right_boundary = xmax + margin * width top_boundary = ymax + margin * height bottom_boundary = ymin - margin * height return [ left_boundary, right_boundary, top_boundary, bottom_boundary ] end end #loglogplot.rb require 'Tioga/FigureMaker' require 'plots.rb' class LogLogPlot < TiogaPlot def initialize(file) super() @data_filename = file t.def_figure('LogLog'){ loglogplot } t.save_dir = 'figures' @mids = Dvector.new @ps = Dvector.new @data = [@mids, at ps] end def read_data Dvector.read(@data_filename, at data) end def loglogplot read_data t.yaxis_log_values = true t.xaxis_log_values = true t.right_edge_type = AXIS_LINE_ONLY t.top_edge_type = AXIS_LINE_ONLY t.xaxis_number_of_minor_intervals = 10 t.yaxis_number_of_minor_intervals = 10 #Dummy data #@mids = [1,2,3,4,5,6,7,8,9,10,11] puts(@mids) t.do_box_labels('Test','EC Codes (k)','p(k)') t.show_plot(plot_boundaries(@mids, at ps, at margin)){ @mids.each_index do |i| t.show_marker('marker' => Bullet, 'point' => [@mids[i], at ps[i]], 'scale' => 0.6, 'color' => Black) end t.show_polyline(@mids, at ps,Blue) } end end #batch.rb require 'Tioga/FigureMaker' require 'loglogplot.rb' class LogLogRun < LogLogPlot def run t.figure_names.each do |name| puts "\nMake #{name}.pdf" t.make_preview_pdf(name) end end end LogLogRun.new(ARGV[0]).run #data 0.1085736 -0.09052523 0.3257209 -0.8954674 0.5428681 -1.330542 0.7600153 -1.991929 0.9771626 -2.635045 1.194310 -3.086276 1.411457 -3.107128 1.628604 -4.064638 2.062899 -4.799963 2.280046 -5.01711 2.497193 -5.234257 Dr Alex Gutteridge Post-Doctoral Researcher Bioinformatics Center Institute for Chemical Research Kyoto University Gokasho, Uji, Kyoto 611-0011 Japan From paxton at kitp.ucsb.edu Wed Apr 26 23:21:44 2006 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Wed, 26 Apr 2006 20:21:44 -0700 Subject: [Tioga-users] Log log plots In-Reply-To: <62598E7A-A606-451A-A4A4-6EAFD3F724B7@kuicr.kyoto-u.ac.jp> References: <62598E7A-A606-451A-A4A4-6EAFD3F724B7@kuicr.kyoto-u.ac.jp> Message-ID: Hi Alex, On Apr 26, 2006, at 7:51 PM, Alex Gutteridge wrote: > when I use my real data the log scale is broken First, thanks very much for sending all the relevant stuff so that I could easily reproduce the problem. Makes life much easier! Second, what you found is a bug at my end, and I'll get to it ASAP. (FYI: Tioga is caught between wanting to put in more major ticks versus the need to do a log axis, and it obviously isn't making the right choice -- but what would you expect it to do if the range of the x-axis was from 1.1 to 9.9, for example, and a log axis was requested? hmmm.) In the meantime, here is a work-around if you'd like. If you tell Tioga where you want to place the major ticks, it won't give the bogus x-axis (at least that is working for me). Try adding the following line to your loglogplot routine: t.xaxis_locations_for_major_ticks = [0, 1, 2] When I do that, I get this plot from your data: ? Hope that helps. Cheers, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/tioga-users/attachments/20060426/43bce434/attachment-0002.htm -------------- next part -------------- A non-text attachment was scrubbed... Name: LogLog_000-1.pdf Type: application/pdf Size: 12781 bytes Desc: not available Url : http://rubyforge.org/pipermail/tioga-users/attachments/20060426/43bce434/attachment-0001.pdf -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/tioga-users/attachments/20060426/43bce434/attachment-0003.htm