when plotting, the legend of the graph is now also output on stdout

- this is a workaround for a bug where the legend often appears trucated on the pdf

work related to [https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=4171]
This commit is contained in:
Guillaume Raffy 2025-10-22 14:53:50 +02:00
parent 716d2d3262
commit 06b05275c2
1 changed files with 8 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import hashlib
from concho.config import Cpu, MemSize, Configurator, Config from concho.config import Cpu, MemSize, Configurator, Config
# from concho import dell # from concho import dell
from pathlib import Path from pathlib import Path
import logging
markerTypes = [',', '+', '.', '^', 'v', '<', '>', 'o', '*', '1', '2', '3', '4', '8', 's', 'p', 'h', 'H', 'x', 'X', 'D', 'd', '|', '_'] markerTypes = [',', '+', '.', '^', 'v', '<', '>', 'o', '*', '1', '2', '3', '4', '8', 's', 'p', 'h', 'H', 'x', 'X', 'D', 'd', '|', '_']
# for c in ascii_lowercase: # for c in ascii_lowercase:
@ -198,6 +199,7 @@ def plot_configs(configs: List[Config], xaxis_def: ConfigAxisDef, yaxis_def: Con
# markersCycler = itertools.cycle(itertools.product(markerTypes, markerColors)) # markersCycler = itertools.cycle(itertools.product(markerTypes, markerColors))
config_index = 0 config_index = 0
legend = {}
for config in configs: for config in configs:
cpu = config.cpu cpu = config.cpu
config_label = str(config.num_servers) + '_' + config.chassis.uid + '_' + str(config.num_cpu_per_server) + '_' + cpu.uid + '_' + str(config.ram_size / config.num_servers) + 'gb' config_label = str(config.num_servers) + '_' + config.chassis.uid + '_' + str(config.num_cpu_per_server) + '_' + cpu.uid + '_' + str(config.ram_size / config.num_servers) + 'gb'
@ -205,14 +207,16 @@ def plot_configs(configs: List[Config], xaxis_def: ConfigAxisDef, yaxis_def: Con
x1 = xaxis_def.get_value_for_config(config) x1 = xaxis_def.get_value_for_config(config)
y1 = yaxis_def.get_value_for_config(config) y1 = yaxis_def.get_value_for_config(config)
print(config_label, x1, y1) logging.info(f'config {config_label}: x={x1}, y={y1}')
if y1 > 0.0001: if y1 > 0.0001:
color = getColorCodeFromItemLabel(config_label) color = getColorCodeFromItemLabel(config_label)
# marker = markersCycler.next() # marker = markersCycler.next()
# marker = get_marker_from_label( label ) # marker = get_marker_from_label( label )
# print(x1, y1) # print(x1, y1)
marker = create_unique_marker(config_index)
short_label = config_label.replace('dell-poweredge-', '').replace('intel-xeon-', '').replace('hpe-proliant-', '').replace('-gen', '-g') short_label = config_label.replace('dell-poweredge-', '').replace('intel-xeon-', '').replace('hpe-proliant-', '').replace('-gen', '-g')
plt.scatter(x1, y1, facecolors=color, s=(markerSize * len(create_unique_marker(config_index))), marker=r'$\mathrm{%s}$' % create_unique_marker(config_index), label=short_label) plt.scatter(x1, y1, facecolors=color, s=(markerSize * len(marker)), marker=r'$\mathrm{%s}$' % marker, label=short_label)
legend[marker] = short_label
if False: # y1 > 5.0e16: if False: # y1 > 5.0e16:
plt.annotate(u'%s' % short_label, plt.annotate(u'%s' % short_label,
xy=(x1, y1), xytext=(x1 * 4.0, (y1 - 5.2e16) * 7.1), xy=(x1, y1), xytext=(x1 * 4.0, (y1 - 5.2e16) * 7.1),
@ -231,6 +235,8 @@ def plot_configs(configs: List[Config], xaxis_def: ConfigAxisDef, yaxis_def: Con
plt.grid(visible=True, which='minor', color='b', linestyle='-', linewidth=0.2) plt.grid(visible=True, which='minor', color='b', linestyle='-', linewidth=0.2)
plt.legend(bbox_to_anchor=(1.1, 1.1), ncol=2) plt.legend(bbox_to_anchor=(1.1, 1.1), ncol=2)
plt.draw() plt.draw()
for marker in legend:
logging.info(f'config {marker}: {legend[marker]}')
if figure_file_path: if figure_file_path:
plt.savefig(figure_file_path) plt.savefig(figure_file_path)
else: else: