Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add normalize option

Use -norm filename() to normalize values against entries in graph
  • Loading branch information...
commit a274122427683979ad38e3aa220a3f7b59f66fdb 1 parent ec42d74
@psyeugenic authored
Showing with 30 additions and 10 deletions.
  1. +1 −0  src/eplot.erl
  2. +29 −10 src/eplot_main.erl
View
1  src/eplot.erl
@@ -19,6 +19,7 @@ usage() ->
"\t-render_engine Engine :: alpha | opaque, type of render engine\r\n"
"\t-type Type :: png | raw_bitmap, output type\r\n"
"\t-plot Plot :: plot2d | bar2d, plot type\r\n"
+ "\t-norm File :: filename(), normalize against\r\n"
"\t-width Width :: integer(), Width\r\n"
"\t-height Height :: integer(), Height\r\n"
"\t-x_label Label :: string(), X-axis label\r\n"
View
39 src/eplot_main.erl
@@ -3,22 +3,14 @@
png(Inputs, Output, Options0) ->
Options = merge_options(Options0, get_config()),
- Data0 = parse_data_files(Inputs),
- Data = case proplists:is_defined(speedup, Options) of
- true -> data_speedup(Data0);
- false -> Data0
- end,
+ Data = process_data(parse_data_files(Inputs), Options),
B = graph_binary(proplists:get_value(plot, Options), Data, Options),
egd:save(B, Output),
ok.
eview(Inputs, Options0) ->
Options = proplists:delete(type, merge_options(Options0, get_config())),
- Data0 = parse_data_files(Inputs),
- Data = case proplists:is_defined(speedup, Options) of
- true -> data_speedup(Data0);
- false -> Data0
- end,
+ Data = process_data(parse_data_files(Inputs), Options),
W = proplists:get_value(width, Options),
H = proplists:get_value(height, Options),
P = eview:start({W,H}),
@@ -26,6 +18,33 @@ eview(Inputs, Options0) ->
P ! {self(), bmp_image, B, {W,H}},
receive {P, done} -> ok end.
+process_data(Data0, Options) ->
+ Data1 = case proplists:is_defined(speedup, Options) of
+ true -> data_speedup(Data0);
+ false -> Data0
+ end,
+ case proplists:is_defined(norm, Options) of
+ true ->
+ [{_Name,Norm}] = parse_data_files([proplists:get_value(norm, Options)]),
+ normalize_data(Data1, Norm);
+ false ->
+ Data1
+ end.
+
+normalize_data([], _) -> [];
+normalize_data([{Name,Data}|Datas], Norm) ->
+ [{Name, normalize_data_entries(Name, Data, Norm)}|normalize_data(Datas, Norm)].
+normalize_data_entries(_, [], _) -> [];
+normalize_data_entries(Name, [{X,Y}|Entries], Norm) ->
+ case proplists:get_value(X, Norm) of
+ undefined ->
+ io:format(standard_error, "Warning: entry ~p not in data file ~p\r\n", [X, Name]),
+ normalize_data_entries(Name, Entries, Norm);
+ Value ->
+ [{X, Y/Value}|normalize_data_entries(Name, Entries, Norm)]
+ end.
+
+
graph_binary(plot2d,Data, Options) ->
egd_chart:graph(Data, Options);
Please sign in to comment.
Something went wrong with that request. Please try again.