1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
| # Ouverture du fichier test
my $fichier = "gcont_83333.dist";
open (F1, "/home/gcadars/matrice/matrice2/$fichier");
# Mes 3 variables
my ( @x, @y, @z );
# Parsing
foreach my $i ( $fichier )
{
# echap les ligne qui commance par un chiffre
next unless ( $i =~ /^[^0-9]/ );
chomp( $i );
# decoupage de la ligne
my @t = split / /, $i;
# ajoute au bon tableau
push @x, shift @t;
push @z, \@t;
}
# copie x -> y
@y = @x;
### FIN ###
#Heatmap
print <<EOF;
</table> </td>
</tr>
</table>
</fieldset>
<fieldset class='accueil'> <legend> HEATMAP </legend>
<head>
<!-- Plotly.js -->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<div id="myDiv"><!-- Plotly chart will be drawn inside this DIV --></div>
<script>
var xValues = @x;
var yValues = @y;
var zValues = @z;
var colorscaleValue = [
[0, '#ffffff'],
[0.1, '#ffe8e8'],
[0.2, '#ffd1d1'],
[0.3, '#ffbcbc'],
[0.4, '#ff9999'],
[0.5,'#ff7f7f'],
[0.6, '#ff6363'],
[0.7, '#ff4c4c'],
[0.8, '#ff3232'],
[0.9, '#fc1b1b'],
[1, '#ff0000']
];
var data = [{
x: xValues,
y: yValues,
z: zValues,
type: 'heatmap',
colorscale: colorscaleValue,
showscale: true
}];
var layout = {
title: 'AAI Heatmap',
annotations: [],
xaxis: {
ticks: '',
side: 'top'
},
yaxis: {
ticks: '',
ticksuffix: ' ',
width: 700,
height: 700,
autosize: false
}
};
for ( var i = 0; i < yValues.length; i++ ) {
for ( var j = 0; j < xValues.length; j++ ) {
var currentValue = zValues[i][j];
if (currentValue != 0.0) {
var textColor = 'black';
}else{
var textColor = 'black';
}
var result = {
xref: 'x1',
yref: 'y1',
x: xValues[j],
y: yValues[i],
text: zValues[i][j],
font: {
family: 'Arial',
size: 12,
color: 'rgb(50, 171, 96)'
},
showarrow: false,
font: {
color: textColor
}
};
layout.annotations.push(result);
}
}
Plotly.newPlot('myDiv', data, layout, {showSendToCloud: true});
</script>
</body>
<p></>
</fieldset>
<td> <table>
EOF |
Partager