Mercurial > repos > bimib > marea_2
changeset 278:c1af8b0b2815 draft
Uploaded
author | luca_milaz |
---|---|
date | Sun, 04 Aug 2024 17:48:17 +0000 |
parents | 9224735e90f0 |
children | 6544f0027c72 |
files | marea_2/flux_to_map.py |
diffstat | 1 files changed, 17 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/marea_2/flux_to_map.py Sun Aug 04 17:17:22 2024 +0000 +++ b/marea_2/flux_to_map.py Sun Aug 04 17:48:17 2024 +0000 @@ -815,25 +815,21 @@ return { id : list(map(utils.Float("Dataset values, not an argument"), values)) for id, values in dataset.items() }, IDs def rgba_to_hex(rgba): - """Convert an RGBA color to HEX format.""" - return '#{:02x}{:02x}{:02x}'.format(int(rgba[0] * 255), int(rgba[1] * 255), int(rgba[2] * 255)) + """Convert an RGBA color to HEX format including alpha.""" + return '#{:02x}{:02x}{:02x}{:02x}'.format(int(rgba[0] * 255), int(rgba[1] * 255), int(rgba[2] * 255), int(rgba[3] * 255)) def gray_to_red_cmap(value): - """Map a normalized value to RGB color transitioning from gray to red.""" value = abs(value) - if value < 0.5: - # Transition from blue to gray - r = 0.5 * value * 2 - g = 0.5 * value * 2 - b = 1 - else: - # Transition from gray to red - value = (value - 0.5) * 2 - r = 1 - g = 1 - value - b = 1 - value + + r = 1 + g = 0 + b = 0 - return (r, g, b) + # Opacity transition from 0.5 to 1 + alpha = 0.5 + 0.5 * value + + return (r, g, b, alpha) + def computeEnrichmentMeanMedian(metabMap :ET.ElementTree, class_pat :Dict[str, List[List[float]]], ids :List[str]) -> None: @@ -874,7 +870,9 @@ for rxn_id in ids: arrow = Arrow(width=5, col=colors_median[rxn_id]) - arrow.applyTo(arrow.getMapReactionId(rxn_id, mindReactionDir=False), metabMap_median, arrow.toStyleStr()) + #arrow.applyTo(arrow.getMapReactionId(rxn_id, mindReactionDir=False), metabMap_median, arrow.toStyleStr()) + arrow.applyTo(getArrowBodyElementId(rxn_id), metabMap_median, arrow.toStyleStr()) + # Now we style the arrow head(s): #idOpt1, idOpt2 = getArrowHeadElementId(arrow.getMapReactionId(rxn_id, mindReactionDir=True)) #arrow.applyTo(idOpt1, metabMap_median, arrow.toStyleStr(downSizedForTips = True)) @@ -883,7 +881,9 @@ #arrow.styleReactionElements(metabMap_median, arrow.getMapReactionId(rxn_id, mindReactionDir=False), mindReactionDir=False) arrow = Arrow(width=5, col=colors_mean[rxn_id]) - arrow.applyTo(arrow.getMapReactionId(rxn_id, mindReactionDir=False), metabMap_mean, arrow.toStyleStr()) + #arrow.applyTo(arrow.getMapReactionId(rxn_id, mindReactionDir=False), metabMap_mean, arrow.toStyleStr()) + arrow.applyTo(getArrowBodyElementId(rxn_id), metabMap_mean, arrow.toStyleStr()) + # Now we style the arrow head(s): #idOpt1, idOpt2 = getArrowHeadElementId(arrow.getMapReactionId(rxn_id, mindReactionDir=True)) #arrow.applyTo(idOpt1, metabMap_mean, arrow.toStyleStr(downSizedForTips = True))