From: Trick Nick Date: 2008-11-26T06:58:45+09:00 Subject: Re: Gruff and labeling ::Realized I didnt have year info gathered from my CSV so i added that but still need help on how to put the dates(Decades) as the x-col values =P require 'net/http' require 'rubygems' require 'gruff' require 'csv' require 'hpricot' pg = Gruff::Line.new form_params = Hash.new countriesString = '' #GET FORM PARAMS form_params = { 'my_vars' => ',+POP', 'my_yrs' => '1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004', 'selected_vars' => 'POP', 'format_selected' => 'csv' } ARGV.each do |arg| countriesString << ",\"#{arg.to_s}\"" form_params['my_countries'] = "#{countriesString}" #FORM PARAMS COMPLETED #COLLECT DATA results = Net::HTTP.post_form(URI.parse('http://pwt.econ.upenn.edu/php_site/pwt62/pwt62_retrieve.php'), form_params) parse_page = Hpricot(results.body) popData_H = (parse_page/"pre").inner_html popCSV = CSV.parse(popData_H.to_s {|f| f.read}) #END COLLECT DATA #PREPARE TO GRAPH label = arg popdata = popCSV.map { |x| x[3].to_i } yeardata = popCSV.map { |x| x[2].to_i } popdata.delete(0) yeardata.delete(0) yeardata.each do |x| if x % 10 == 0 || x == 1951 || x == 2004 labels = yeardata[2] end end pg.data(label, popdata) pg.x_axis_label = "Years" pg.y_axis_label = "Population" countriesString = '' end puts pg.methods.sort pg.write('population_graph.png') -- Posted via http://www.ruby-forum.com/.