diff --git a/bin/logtool b/bin/logtool
index 19b3e8051b1e1335e18030d2c645b9eda40c315e..7047935061cc6f3b4bf28a538ca65355bff14719 100755
--- a/bin/logtool
+++ b/bin/logtool
@@ -12,6 +12,7 @@ following:
 "plot expr_x,expr_y" to plot a graph,
 "datafile outfile expr_x,expr_y" to write out a data file.
 "table variable" to print the full data table for a time series variable.
+"prefix string" to set the legend prefix for all following plot commands.
 """
     parser = OptionParser(usage="%prog FILE COMMANDS FILE COMMANDS...",
             description=description)
@@ -52,6 +53,8 @@ following:
 
     did_plot = False
 
+    legend_prefix = ""
+
     def check_no_file():
         if logmgr is None:
             raise RuntimeError, "no file loaded"
@@ -110,9 +113,9 @@ following:
             kwargs = {}
 
             if options.legend_expr:
-                kwargs["label"] = expr_y
+                kwargs["label"] = legend_prefix+expr_y
             if options.legend_descr:
-                kwargs["label"] = descr_y
+                kwargs["label"] = legend_prefix+descr_y
 
             plot(data_x, data_y, hold=True, **kwargs)
 
@@ -123,6 +126,8 @@ following:
             expr_x, expr_y = args.pop(0).split(",")
 
             logmgr.write_datafile(args.pop(0), expr_x, expr_y)
+        elif cmd == "prefix":
+            legend_prefix = args.pop(0)
         elif cmd == "table":
             check_no_file()