Skip to content

dimension ruby #10

@HUSSEINSALEEM

Description

@HUSSEINSALEEM

require 'gruff'

Sample data for MIELE function

x_values = [10, 100, 1000, 3000, 5000]
hs_method_data = [505, 567, 675, 920, 917]
new_three_term_method_data = [471, 530, 628, 911, 946]

Create a new line graph

g = Gruff::Line.new
g.title = 'Optimization (Number of Function Evaluations)'
g.labels = {
0 => '10',
1 => '100',
2 => '1000',
3 => '3000',
4 => '5000'
}

Add data series

g.data(:'HS method', hs_method_data)
g.data(:'New Three-Term method', new_three_term_method_data)

Customize the graph

g.x_axis_label = 'Dimension (Ruby output)'
g.y_axis_label = 'Numerical Results'
g.marker_font_size = 12
g.legend_font_size = 12
g.show_legend = true

Render the graph to a file

g.write('optimization_chart.png')

To display the chart on the screen (if needed)

Uncomment the following line if you have a GUI environment

g.draw

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions