2016-04-19 5 views
4

Ich verwende gnuplot in dumm Plot-Modus (Plot direkt im Terminal), um Überwachungs-Tools in der Befehlszeile zu bauen. Ich möchte meinen Graphen Farben hinzufügen.Injects Farben in Graphen von gnuplot in Begriff dumm Plot-Modus generiert

Hier ist eine einfache Ansicht:

> gnuplot5 -e "set term dumb 70 20; plot 'file1' pt '@'" 

100 [email protected] 
    +   +   +   +   +   +   + 
90 +-+           'file1' @ +-+ 
80 +-+          @     +-+ 
    |               | 
70 +-+        @      +-+ 
    |               | 
60 +-+       @       +-+ 
50 +-+      @        +-+ 
    |               | 
40 +-+     @          +-+ 
    |               | 
30 +-+   @           +-+ 
20 +-+  @            +-+ 
    +   +   +   +   +   +   + 
10 [email protected]+---------+---------+---------+---------+-------+-+ 
    0   10  20  30  40  50  60 

mit file1:

5 10 
10 20 
15 30 
20 40 
25 50 
30 60 
35 70 
40 80 
50 90 
60 100 

Mein Versuch, Farben hinzuzufügen:

> gnuplot5 -e "set term dumb 70 20; plot 'file1' pt '@'" | 
      sed 's|@|\\\033[[email protected]\\\033[0m|g' | cat -v 

100 +-+-------+---------+---------+---------+---------+-------+-\@33[[email protected]\@33[0m 
    +   +   +   +   +   +   + 
90 +-+           'file1' \@33[[email protected]\@33[0m +-+ 
80 +-+          \@33[[email protected]\@33[0m     +-+ 
    |               | 
70 +-+        \@33[[email protected]\@33[0m      +-+ 
    |               | 
60 +-+       \@33[[email protected]\@33[0m       +-+ 
50 +-+      \@33[[email protected]\@33[0m        +-+ 
    |               | 
40 +-+     \@33[[email protected]\@33[0m          +-+ 
    |               | 
30 +-+   \@33[[email protected]\@33[0m           +-+ 
20 +-+  \@33[[email protected]\@33[0m            +-+ 
    +   +   +   +   +   +   + 
10 +-+--\@33[[email protected]\@33[0m----+---------+---------+---------+---------+-------+-+ 
    0   10  20  30  40  50  60 
+0

Versuchen Sie, die 'caca' Terminal für das, was mit der Version 5.0 verfügbar ist, erfordert aber libcaca finden https://sourceforge.net/p/gnuplot/feature-requests/346/ – Christoph

+0

thx, dass ordentlich ist. Das Problem ist, ich möchte das Skript nicht von anderen Bibliotheken abhängig machen. Da ich es auf einem Cluster ausführen möchte, ist die Abhängigkeit umso besser. Wie kann ich Farben mit "sed" oder einem anderen gängigen Werkzeug injizieren? – jyvet

Antwort

4

Lösung 1

Verwenden Sie grep --colors=always <pattern>, es verwendet Grep Standard-Farbhervorhebung.

> gnuplot5 -e "set term dumb 70 20; plot 'file1' pt '@'" | 
      grep --color=always '@' 

Lösung 2

Verwendung colout <pattern> <color>. Es hat die Fähigkeit, die Farbe auszuwählen, aber eine Python-Bibliothek muss installiert werden (pip install colout).

> gnuplot5 -e "set term dumb 70 20; plot 'file1' pt '@'" | colout '@' green