Lo hice de la siguiente manera por si a alguien le interesa
Código PHP:
$lista_colores = array('red','blue','green','yellow');
while($dat2 = $db->fetch($opts)) {
$id_opt = $dat2['id_opt'];
$opciones = $dat2['opciones'];
$num_votos = $dat2['num_votos'];
$ptos = $num_votos * 100;
$porcentaje = @round($ptos/$tot,0);
if ($porcentaje <= 25) {
$color = $lista_colores[0];
} elseif ($porcentaje >= 26 and $porcentaje <= 50) {
$color = $lista_colores[1];
} elseif ($porcentaje >= 51 and $porcentaje <= 75) {
$color = $lista_colores[2];
} elseif ($porcentaje >= 76) {
$color = $lista_colores[3];
}