From 595cbc64adbd8fe1e0e8e840bc89b423b3bde9d4 Mon Sep 17 00:00:00 2001 From: Simon Let Date: Thu, 5 Mar 2020 23:10:08 +0100 Subject: [PATCH] uncomment all plots, use serif font, minor changes --- pkg/histanal/histload.go | 3 +-- scripts/resh-evaluate-plot.py | 32 ++++++++++++++++++++------------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/pkg/histanal/histload.go b/pkg/histanal/histload.go index 17497e5..2bc50b1 100644 --- a/pkg/histanal/histload.go +++ b/pkg/histanal/histload.go @@ -169,8 +169,7 @@ func (e *HistLoad) loadHistoryRecords(fname string) []records.EnrichedRecord { log.Fatal("Assert failed - 'cmdLength' is set in raw data. Maybe you want to use '--sanitized-input' option?") } record.CmdLength = len(record.CmdLine) - } - if record.CmdLength == 0 { + } else if record.CmdLength == 0 { log.Fatal("Assert failed - 'cmdLength' is unset in the data. This should not happen.") } recs = append(recs, records.Enriched(record)) diff --git a/scripts/resh-evaluate-plot.py b/scripts/resh-evaluate-plot.py index 4ffea19..f1aee96 100755 --- a/scripts/resh-evaluate-plot.py +++ b/scripts/resh-evaluate-plot.py @@ -5,12 +5,17 @@ import traceback import sys import json from collections import defaultdict -import matplotlib.pyplot as plt -import matplotlib.path as mpath import numpy as np from graphviz import Digraph from datetime import datetime +from matplotlib import rcParams +rcParams['font.family'] = 'serif' +# rcParams['font.serif'] = [''] + +import matplotlib.pyplot as plt +import matplotlib.path as mpath + PLOT_WIDTH = 10 # inches PLOT_HEIGHT = 7 # inches @@ -252,13 +257,13 @@ def graph_cmdSequences(node_count=33, edge_minValue=0.05, view_graph=True): #penwidth_bold_ = str(8 * scale_) if scale_ > 0.5: graph.edge(cmd_id[cmd], cmd_id[cmd2], constraint='true', splines='curved', - penwidth=penwidth_, style='bold') + penwidth=penwidth_, style='bold', arrowhead='diamond') elif scale_ > 0.2: graph.edge(cmd_id[cmd], cmd_id[cmd2], constraint='true', splines='curved', - penwidth=penwidth_, arrowhead='open') + penwidth=penwidth_) elif scale_ > 0.1: graph.edge(cmd_id[cmd], cmd_id[cmd2], constraint='true', splines='curved', - penwidth=penwidth_, style='dashed', arrowhead='open') + penwidth=penwidth_, style='dashed') else: graph.edge(cmd_id[cmd], cmd_id[cmd2], constraint='false', splines='curved', penwidth=penwidth_, style='dotted', arrowhead='empty') @@ -335,6 +340,7 @@ def plot_strategies_matches(plot_size=50, selected_strategies=[]): assert(saved_matches_total is not None) assert(saved_dataPoint_count is not None) max_values = [100 * saved_matches_total / saved_dataPoint_count] * len(x_values) + print(">>> Avg recurrence rate = {}".format(max_values[0])) plt.plot(x_values, max_values, 'r-') legend.append("maximum possible") @@ -406,6 +412,7 @@ def plot_strategies_charsRecalled(plot_size=50, selected_strategies=[]): assert(saved_charsRecalled_total is not None) assert(saved_dataPoint_count is not None) max_values = [saved_charsRecalled_total / saved_dataPoint_count] * len(x_values) + print(">>> Max avg recalled characters = {}".format(max_values[0])) plt.plot(x_values, max_values, 'r-') legend.append("maximum possible") @@ -481,6 +488,7 @@ def plot_strategies_charsRecalled_prefix(plot_size=50, selected_strategies=[]): assert(saved_charsRecalled_total is not None) assert(saved_dataPoint_count is not None) max_values = [saved_charsRecalled_total / saved_dataPoint_count] * len(x_values) + print(">>> Max avg recalled characters (including prefix matches) = {}".format(max_values[0])) plt.plot(x_values, max_values, 'r-') legend.append("maximum possible") @@ -494,19 +502,19 @@ def plot_strategies_charsRecalled_prefix(plot_size=50, selected_strategies=[]): plt.show() -# plot_cmdLineFrq_rank() -# plot_cmdFrq_rank() +plot_cmdLineFrq_rank() +plot_cmdFrq_rank() -# plot_cmdLineVocabularySize_cmdLinesEntered() -# plot_cmdVocabularySize_cmdLinesEntered() +plot_cmdLineVocabularySize_cmdLinesEntered() +plot_cmdVocabularySize_cmdLinesEntered() plot_strategies_matches(20) plot_strategies_charsRecalled(20) -# plot_strategies_charsRecalled_prefix(20) +plot_strategies_charsRecalled_prefix(20) -# graph_cmdSequences(node_count=33, edge_minValue=0.048) +graph_cmdSequences(node_count=33, edge_minValue=0.048) -# graph_cmdSequences(node_count=28, edge_minValue=0.06) +graph_cmdSequences(node_count=28, edge_minValue=0.06) # for n in range(29, 35): # for e in range(44, 56, 2):