ユーザ用ツール

サイト用ツール


algraph:散布図

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
algraph:散布図 [2019/04/07 19:48] hirohitoalgraph:散布図 [2019/12/18 15:59] (現在) hirohito
行 4: 行 4:
 <code html index.html> <code html index.html>
 <!DOCTYPE html> <!DOCTYPE html>
-<object width="320" height="240" type="image/svg+xml" data="<%= Alone.make_uri(action:'graph_sample') %>"></object>+<img src="<%=Alone::make_uri(:action => 'scatter_sample_01') %>">
 </code> </code>
  
行 17: 行 17:
   end   end
  
-  def action_graph_sample()+  # 散布図1 
 +  def action_scatter_sample_01 
 +    # 竹村彰通(統計 共立出版より引用
     data_m = [[172,70],[176,69],[170,70],[174,70],[170,62],     data_m = [[172,70],[176,69],[170,70],[174,70],[170,62],
               [167,50],[175,75],[179,80],[162,60],[169,80]]               [167,50],[175,75],[179,80],[162,60],[169,80]]
行 56: 行 58:
  
   graph.add_data( [x1,x2,..], [y1, y2,...] )   graph.add_data( [x1,x2,..], [y1, y2,...] )
 +
 +
 +====== サンプル ======
 +
 +リリースファイルでサンプルとして提供しているものです。
 +
 +
 +===== バブルチャートにアレンジ =====
 +
 +{{:algraph:scatter_sample_02.png?320 |}}
 +
 +
 +<code ruby>
 +  def action_scatter_sample_02
 +    group_A_x =    [ 23,  24,  62   ,9]
 +    group_A_y =    [ -4,   5,  12, -10]
 +    group_A_size = [ 50,  40,  90,  20]
 +
 +    group_B_x =    [ 39,  20,   5,  85]
 +    group_B_y =    [  0,  10, -14,  -6]
 +    group_B_size = [ 40,  50,  10,  40]
 +    group_label = ["農林", "製造", "建築土木", "その他"]
 +
 +    graph = AlGraphScatter.new(800,600)
 +    graph.color_list = ["#88f", "#f88"]
 +    graph.shape_list = [:circle, :circle]
 +
 +    graph.add_xaxis_title("X軸タイトル")
 +    graph.add_yaxis_title("Y軸タイトル")
 +    graph.x_axis.at_labels[:format] = "%.0f%%"
 +    graph.x_axis.min = 0
 +    graph.x_axis.max = 90
 +    graph.y_axis.at_labels[:format] = "%.0f%%"
 +    graph.y_axis.min = -15
 +    graph.y_axis.max = 25
 +
 +    data = graph.add_data( group_A_x, group_A_y, "男性" )
 +    data.add_data_labels(:CENTER)
 +    data.labels = group_label
 +    data.at_data_labels[:font_size] = 20
 +    group_A_size.each_with_index {|sz,i|
 +      data.at_marker_several[i] = {:size=>sz, :stroke_width=>3,:stroke=>"#fff"}
 +    }
 +
 +    data = graph.add_data( group_B_x, group_B_y, "女性" )
 +    data.add_data_labels(:CENTER)
 +    data.labels = group_label
 +    data.at_data_labels[:font_size] = 20
 +    group_B_size.each_with_index {|sz,i|
 +      data.at_marker_several[i] = {:size=>sz, :stroke_width=>3,:stroke=>"#fff"}
 +    }
 +
 +    graph.draw
 +  end
 +</code>
  
algraph/散布図.txt · 最終更新: 2019/12/18 15:59 by hirohito