my $p;
my $storefile;
+my $plotstring;
use constant {TYPE_HISTORY => 1, TYPE_BARGRAPH => 2, TYPE_HEATMAP => 3};
OUT_SVG => 2, #n/a
OUT_SCREEN => 3}; #n/a
-my @color= ('#2222dd','#dd2222','#22dd22','#dd8822','#dd22dd','#22dddd','#dddd22','#8888dd','#8822bb','#444444','#2222dd','#dd2222','#22dd22','#dd8822','#dd22dd','#22dddd','#dddd22','#8888dd','#8822bb','#444444',);
+my @color= ('#2222dd','#dd2222','#22dd22','#dd8822','#dd22dd','#22dddd','#dddd22','#8888dd','#8822bb','#444444',
+ '#2222dd','#dd2222','#22dd22','#dd8822','#dd22dd','#22dddd','#dddd22','#8888dd','#8822bb','#444444');
sub plot_write {
- my ($file,$str,$no) = @_;
+ my ($file,$str,$no,$save) = @_;
return unless $str;
if($no || 0) {
print $file $str;
-# print $str;
+# print $str;
}
else {
print $file $str."\n";
-# print $str."\n";
+# print $str."\n";
}
+ if(defined $save) {$plotstring->{$save} .= $str;}
}
}
}
-
-
sub PlotInit {
my ($c) = @_;
my $fn = "gnuplot";
#my $fh = new FileHandle ("|$fn") or die "error: no gnuplot";
open my $fh, "|$fn" or die "error: no gnuplot";
- #open my $fh, ">delme_$name" or die "error: no gnuplot";
$fh->autoflush(1);
$p->{$name}->{showvalues} = $p->{$name}->{showvalues} || 0;
$p->{$name}->{storable} = $p->{$name}->{storable} || 0;
$p->{$name}->{plot_string} = ""; # to store the plot command
+ $p->{$name}->{xticks} = $p->{$name}->{xticks} || 0;
$p->{$name}{additional} = $p->{$name}{additional} || '';
my $filename = $p->{$name}->{file};
$filename =~ s%/%%;
- $storefile->{$name} = "/dev/shm/".$name.'-'.$p->{$name}->{curves}.'-'.$p->{$name}->{entries}.'-'.$filename.'.store';
+ $storefile->{$name} = $name.'-'.$p->{$name}->{curves}.'-'.$p->{$name}->{entries}.'-'.$filename.'.store';
+ $storefile->{$name} =~ s%/%%g;
+ $storefile->{$name} = "/dev/shm/".$storefile->{$name};
unless ($p->{$name}{noinit}) {
foreach my $i (0..($c->{entries}-1)) {
if($p->{$name}->{output} == OUT_PNG) {
$p->{$name}->{file} or die "No filename specified";
- plot_write($fh,"set term png size ".$p->{$name}->{sizex}.",".$p->{$name}->{sizey}." font \"monospace,8\"");
+ plot_write($fh,"set term png size ".$p->{$name}->{sizex}.",".$p->{$name}->{sizey}." truecolor font \"monospace,8\"");
plot_write($fh,"set out \"".$p->{$name}->{file}.($p->{$name}->{buffer}?"tmp":"").".png\"");
}
elsif($p->{$name}->{output} == OUT_SCREEN) {
setranges($fh,'zrange',$p->{$name}->{zmin},$p->{$name}->{zmax});
setranges($fh,'cbrange',$p->{$name}->{cbmin},$p->{$name}->{cbmax});
+ if($p->{$name}->{addCmd} && $p->{$name}->{addCmd} ne "") {
+ plot_write($fh,$p->{$name}->{addCmd});
+ }
+
if ($p->{$name}->{type} == TYPE_HISTORY) {
if ($p->{$name}->{fill}) {
plot_write($fh,"set style fill solid 1.00");
}
elsif ($p->{$name}->{type} == TYPE_BARGRAPH) {
my $stacked = $p->{$name}{stacked}?'rowstacked':'';
+ #print $stacked;
plot_write($fh,"set style fill solid 1.00 ");
plot_write($fh,"set grid noxtics ytics");
plot_write($fh,"set boxwidth ".($p->{$name}->{curvewidth}||4)." absolute");
plot_write($fh,"set style histogram ".$stacked." gap ".($p->{$name}->{bargap}||1));
+
+ if($p->{$name}->{xticks}) {
+ plot_write("set xtics rotate by 90 offset .7,-1.7 scale .7 ");
+ }
+
if (defined $p->{$name}->{bartitle} && scalar @{$p->{$name}->{bartitle}}) {
plot_write($fh,"set xtics (",1);
for (my $j=0; $j<scalar @{$p->{$name}->{bartitle}};$j++) {
#plot_write($fh,"plot ",1);
$p->{$name}->{plot_string} .= "plot ";
for (my $j=0; $j<$p->{$name}->{curves};$j++) {
- #plot_write($fh,', ',1) if $j;
+ ##plot_write($fh,', ',1) if $j;
$p->{$name}->{plot_string} .= ', ' if $j;
- #plot_write($fh,"'-' lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ",1);
- $p->{$name}->{plot_string} .= "'-' lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ";
+ ##plot_write($fh,"'-' lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ",1);
+ #$p->{$name}->{plot_string} .= "'-' lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ";
+
+ $p->{$name}->{plot_string} .= "'-' with histograms ";
+ $p->{$name}->{plot_string} .= "using 2:xticlabels(1) " if ($p->{$name}->{xticks});
+ $p->{$name}->{plot_string} .= "lt rgb \"".$p->{$name}->{colors}->[$j]."\" title \"".($p->{$name}->{titles}->[$j] || "$j")."\" ";
}
#plot_write($fh," ");
$p->{$name}->{plot_string} .= " \n";
}
elsif ($p->{$name}->{type} == TYPE_HEATMAP) {
plot_write($fh,"set view map");
- plot_write($fh,"set palette rgbformulae 22,13,-31");
+ if(defined $p->{$name}->{palette}) {
+ plot_write($fh,"set palette ".$p->{$name}->{palette});
+ }
+ else {
+ plot_write($fh,"set palette rgbformulae 22,13,-31");
+ }
plot_write($fh,$p->{$name}{additional});
if ($p->{$name}->{showvalues} == 0) {
#plot_write($fh,"splot '-' matrix with image");
if($p->{$name}->{run}>=1) {
plot_write($p->{$name}->{fh},"set out \"".$p->{$name}->{file}.($p->{$name}->{buffer}?"tmp":"").".png\"");
plot_write($p->{$name}->{fh},makeTimeString());
- #plot_write($p->{$name}->{fh},"replot");
plot_write($p->{$name}->{fh}, $p->{$name}->{plot_string});
}
+
+
if($p->{$name}->{type} == TYPE_HISTORY) {
my $realentries = $p->{$name}{limitentries} || $p->{$name}->{entries};
for(my $j=0; $j<$p->{$name}->{curves}; $j++) {
plot_write($p->{$name}->{fh},(($i-($p->{$name}->{entries}-$realentries))/$p->{$name}->{xscale})." ".$p->{$name}->{value}->[$j]->[$i]);
}
else {
- plot_write($p->{$name}->{fh},(($i-$realentries)/$p->{$name}->{xscale})." ".($p->{$name}->{value}->[$j]->[$i]||0));
+ plot_write($p->{$name}->{fh},(($i-$realentries)/($p->{$name}->{xscale}||1))." ".($p->{$name}->{value}->[$j]->[$i]||0));
}
}
plot_write($p->{$name}->{fh},"e");
}
if($p->{$name}->{type} == TYPE_BARGRAPH) {
- my $realentries = $p->{$name}{limitentries} || $p->{$name}{entries};
- #plot_write($p->{$name}->{fh}, $p->{$name}->{plot_string});
- for(my $j=0; $j<$p->{$name}{curves}; $j++) {
- for(my $i=$p->{$name}{entries}-$realentries; $i< $p->{$name}{entries}; $i++) {
- plot_write($p->{$name}{fh},' '.$p->{$name}{value}[$j][$i]||0);
+ my $realentries = $p->{$name}{limitentries} || $p->{$name}->{entries};
+ for(my $j=0; $j<$p->{$name}->{curves}; $j++) {
+ for(my $i=$p->{$name}->{entries}-$realentries; $i< $p->{$name}->{entries}; $i++) {
+ plot_write($p->{$name}->{fh},' '.$p->{$name}->{value}->[$j]->[$i]||0); #?? maybe without ||0
}
- plot_write($p->{$name}{fh},"e");
+ plot_write($p->{$name}->{fh},"e");
}
}
+
if($p->{$name}->{type} == TYPE_HEATMAP) {
+ # if($p->{$name}->{showvalues}) {
for(my $j=0; $j<$p->{$name}->{curves}; $j++) {
for(my $i=0; $i< $p->{$name}->{entries}; $i++) {
plot_write($p->{$name}->{fh},($p->{$name}->{value}->[$j]->[$i]//'NaN')." ",1);#"NaN"
}
plot_write($p->{$name}->{fh},"e");
plot_write($p->{$name}->{fh},"e");
+ # }
+
if ($p->{$name}{showvalues}) {
for(my $j=0; $j<$p->{$name}->{curves}; $j++) {
for(my $i=0; $i< $p->{$name}->{entries}; $i++) {
$p->{$name}{limitentries} = $entries;
}
+
1;