Ruby: создание графика функции

Это - то, как Вы делаете это на любой другой платформе, но это не работает в Windows:

cout << "\f";

, Возможно, необходимо будет сделать условную компиляцию:

void clrscr()
{
#ifdef _WIN32
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coord = {0, 0};
    DWORD count;
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    GetConsoleScreenBufferInfo(hStdOut, &csbi);
    FillConsoleOutputCharacter(hStdOut, ' ',
                               csbi.dwSize.X * csbi.dwSize.Y,
                               coord, &count);
    SetConsoleCursorPosition(hStdOut, coord);
#else
    cout << "\f";
#endif
}
6
задан gmile 1 November 2011 в 12:33
поделиться

4 ответа

Is gnuplot возможный вариант?:

require 'gnuplot.rb'
Gnuplot.open { |gp|
    Gnuplot::Plot.new( gp ) { |plot|
        plot.output "testgnu.pdf"
        plot.terminal "pdf colour size 27cm,19cm"

        plot.xrange "[-10:10]"
        plot.title  "Sin Wave Example"
        plot.ylabel "x"
        plot.xlabel "sin(x)"

        plot.data << Gnuplot::DataSet.new( "sin(x)" ) { |ds|
            ds.with = "lines"
            ds.linewidth = 4
        }
        plot.data << Gnuplot::DataSet.new( "cos(x)" ) { |ds|
            ds.with = "impulses"
            ds.linewidth = 4
        }
    }
}
7
ответ дан 9 December 2019 в 20:45
поделиться

Это моя библиотека для построения графиков: SVG :: Graph

1
ответ дан 9 December 2019 в 20:45
поделиться

Мне очень нравится tioga . Он может создавать графики из латекса невероятно высокого качества, готовые к публикации.

0
ответ дан 9 December 2019 в 20:45
поделиться

use SVG::Graph::Line like this:

require 'SVG/Graph/Line'

  fields = %w(Jan Feb Mar);
  data_sales_02 = [12, 45, 21]
  data_sales_03 = [15, 30, 40]

  graph = SVG::Graph::Line.new({
          :height => 500,
          :width => 300,
    :fields => fields,
  })

  graph.add_data({
          :data => data_sales_02,
    :title => 'Sales 2002',
  })

  graph.add_data({
          :data => data_sales_03,
    :title => 'Sales 2003',
  })

  print "Content-type: image/svg+xml\r\n\r\n";
  print graph.burn();
0
ответ дан 9 December 2019 в 20:45
поделиться
Другие вопросы по тегам:

Похожие вопросы: