algraph:棒グラフ
差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン次のリビジョン両方とも次のリビジョン | ||
algraph:棒グラフ [2019/04/07 18:54] – hirohito | algraph:棒グラフ [2019/04/07 19:15] – [棒グラフ アレンジ例2(バックグラウンドイメージ)] hirohito | ||
---|---|---|---|
行 45: | 行 45: | ||
- | デフォルト(再掲) | + | ===== デフォルト(再掲) |
- | {{: | + | {{: |
- | 棒間隔を指定(詰める) | + | <code ruby> |
+ | def action_bar_sample_01 | ||
+ | ydata1 = [5, 3, 6, 3, 2, 5, 6] | ||
+ | ydata2 = [0, 1, 4, 10, 9, 13, 3] | ||
- | {{: | + | graph = AlGraph.new |
+ | graph.add_data_bar(ydata1, | ||
+ | graph.add_data_bar(ydata2, | ||
- | 棒間隔を指定(開ける) | + | graph.draw |
+ | end | ||
+ | </ | ||
- | {{: | ||
- | 色、透明度アレンジ | + | ===== 棒間隔を指定(詰める) ===== |
- | {{:algraph:bar_sample_04.png? | + | {{:algraph:bar_sample_02.png?nolink |}} |
- | 積み重ね棒グラフ | + | <code ruby> |
+ | def action_bar_sample_02 | ||
+ | ydata1 = [5, 3, 6, 3, 2, 5, 6] | ||
+ | ydata2 = [0, 1, 4, 10, 9, 13, 3] | ||
- | {{: | + | graph = AlGraph.new |
+ | graph.add_data_bar(ydata1, | ||
+ | graph.add_data_bar(ydata2, | ||
- | 棒グラフ アレンジ例 | + | graph.bar_plot.spacing = 0 |
- | {{: | + | graph.draw |
+ | end | ||
+ | </ | ||
- | 棒グラフ アレンジ例2(バックグラウンドイメージ) | ||
- | {{: | + | ===== 棒間隔を指定(開ける) ===== |
+ | |||
+ | {{: | ||
+ | |||
+ | <code ruby> | ||
+ | def action_bar_sample_03 | ||
+ | ydata1 = [5, 3, 6, 3, 2, 5, 6] | ||
+ | ydata2 = [0, 1, 4, 10, 9, 13, 3] | ||
+ | |||
+ | graph = AlGraph.new | ||
+ | graph.add_data_bar(ydata1, | ||
+ | graph.add_data_bar(ydata2, | ||
+ | |||
+ | graph.bar_plot.overlap = -100 | ||
+ | |||
+ | graph.draw | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== 色、透明度アレンジ ===== | ||
+ | |||
+ | {{: | ||
+ | |||
+ | <code ruby> | ||
+ | def action_bar_sample_04 | ||
+ | ydata1 = [5, 3, 6, 3, 2, 5, 6] | ||
+ | ydata2 = [0, 1, 4, 10, 9, 13, 3] | ||
+ | |||
+ | graph = AlGraph.new | ||
+ | bar1 = graph.add_data_bar(ydata1, | ||
+ | bar2 = graph.add_data_bar(ydata2, | ||
+ | |||
+ | bar1.color = ' | ||
+ | bar2.color = ' | ||
+ | bar2.at_bar[: | ||
+ | |||
+ | graph.bar_plot.overlap = 30 | ||
+ | graph.bar_plot.spacing = 50 | ||
+ | |||
+ | graph.draw | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== 積み重ね棒グラフ ===== | ||
+ | |||
+ | {{: | ||
+ | |||
+ | <code ruby> | ||
+ | def action_bar_sample_05 | ||
+ | ydata1 = [5, 3, 6, 3, 2, 5, 6] | ||
+ | ydata2 = [0, 1, 4, 10, 9, 13, 3] | ||
+ | ydata3 = [8, 1, 8, 5, 7, 3, 6] | ||
+ | |||
+ | graph = AlGraph.new | ||
+ | bar1 = graph.add_data_bar(ydata1, | ||
+ | bar2 = graph.add_data_bar(ydata2, | ||
+ | bar3 = graph.add_data_bar(ydata3, | ||
+ | |||
+ | graph.draw | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== 棒グラフ アレンジ例 ===== | ||
+ | |||
+ | {{: | ||
+ | |||
+ | <code ruby> | ||
+ | def action_bar_sample_07 | ||
+ | ydata1 = [ 7, 4, 6 ] | ||
+ | ydata2 = [ 4, 5, 3 ] | ||
+ | ydata3 = [ 2, 3, 5 ] | ||
+ | |||
+ | graph = AlGraph.new | ||
+ | |||
+ | b1 = graph.add_data_bar(ydata1, | ||
+ | b2 = graph.add_data_bar(ydata2, | ||
+ | b3 = graph.add_data_bar(ydata3, | ||
+ | b1.at_bar[: | ||
+ | b2.at_bar[: | ||
+ | b3.at_bar[: | ||
+ | |||
+ | graph.bar_plot.spacing = 30 | ||
+ | |||
+ | graph.set_margin(nil, | ||
+ | graph.at_graph_area[: | ||
+ | graph.at_plot_area[: | ||
+ | graph.at_legend[: | ||
+ | graph.at_legend[: | ||
+ | graph.at_legend[: | ||
+ | |||
+ | graph.x_axis.add_grid | ||
+ | graph.x_axis.at_scale_line[: | ||
+ | graph.x_axis.at_interval_marks[: | ||
+ | graph.x_axis.at_interval_marks[: | ||
+ | graph.x_axis.at_labels[: | ||
+ | graph.x_axis.set_labels([' | ||
+ | graph.x_axis.at_labels[: | ||
+ | |||
+ | graph.y_axis.at_scale_line[: | ||
+ | graph.y_axis.at_interval_marks[: | ||
+ | graph.y_axis.at_interval_marks[: | ||
+ | graph.y_axis.at_labels[: | ||
+ | graph.y_axis.max = 15 | ||
+ | graph.y_axis.min = 0 | ||
+ | graph.y_axis.interval = 5 | ||
+ | graph.y_axis.at_labels[: | ||
+ | |||
+ | graph.add_text(100, | ||
+ | |||
+ | graph.draw | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== 棒グラフ アレンジ例2(バックグラウンドイメージ) ===== | ||
+ | |||
+ | {{: | ||
+ | |||
+ | <code ruby> | ||
+ | def action_bar_sample_08 | ||
+ | ydata1 = [5, 3, 6, 3, 2, 5, 6] | ||
+ | ydata2 = [0, 1, 4, 10, 9, 13, 3] | ||
+ | |||
+ | graph = AlGraph.new | ||
+ | graph.add_data_bar(ydata1, | ||
+ | graph.add_data_bar(ydata2, | ||
+ | graph.at_graph_area[: | ||
+ | graph.at_plot_area[: | ||
+ | |||
+ | graph.draw | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | (注意)2019/ | ||
algraph/棒グラフ.txt · 最終更新: 2019/04/07 19:33 by hirohito