修改深色模式下结果图片显示异常

This commit is contained in:
xinzhu.yin
2026-06-05 16:58:46 +08:00
parent 49d82da8b9
commit e9a591bf6e
11 changed files with 385 additions and 140 deletions

View File

@@ -9,7 +9,10 @@ from typing import TYPE_CHECKING
from matplotlib.patches import Rectangle
from matplotlib.lines import Line2D
from matplotlib.patches import Circle
import matplotlib.colors as mcolors
import numpy as np
from app.views.modern_styles import get_theme_palette
from app.plots.gamut_background import get_cie1976_background
from app.tests.color_accuracy import get_accuracy_color_standards
@@ -112,6 +115,9 @@ def _draw_left_panel(ax, color_patches, delta_e_values, font_scale=1.0, dark_mod
spine.set_linewidth(0.9)
# ============================================================
# 子图CIE 1976 u'v' 色度图(目标 vs 实测)
# ============================================================
@@ -121,12 +127,14 @@ def _draw_uv_diagram(ax, color_patches, measurements, standards, font_scale=1.0,
ax.clear()
try:
bg, bbox = get_cie1976_background()
if bg.shape[-1] == 4:
bg = bg[:, :, :3]
xmin, xmax, ymin, ymax = bbox
ax.imshow(
bg,
extent=(xmin, xmax, ymin, ymax),
origin="lower",
interpolation="bicubic",
interpolation="bilinear",
zorder=0,
aspect="auto",
)
@@ -181,8 +189,10 @@ def _draw_uv_diagram(ax, color_patches, measurements, standards, font_scale=1.0,
s_u, s_v = _xy_to_uv(sx, sy)
# face = get_patch_color_from_xy(name, (sx, sy)).strip().upper()
face = _COLOR_MAP.get(name, "#888888")
print(name, face)
face = _COLOR_MAP.get(name, "#FFFFFF")
# face = get_patch_color_from_xy(name, (mx, my))
# face = "#FF0000"
# 目标点Target 空心方框
ax.scatter(
@@ -300,17 +310,24 @@ def _draw_result_judgement(ax, accuracy_data, font_scale=1.0, dark_mode=False):
def plot_accuracy(self: "PQAutomationApp", accuracy_data, test_type):
"""绘制色准测试结果 - Calman 风格(色块 + CIE 1976 u'v' + 统计)。"""
fig = self.accuracy_fig
fig.clear()
palette = get_theme_palette()
try:
from app.views.theme_manager import is_dark
dark_mode = is_dark()
except Exception:
dark_mode = False
fig.patch.set_facecolor("#1B1F24" if dark_mode else "#FFFFFF")
fig = self.accuracy_fig
fig.clear()
try:
fig.set_layout_engine(None)
except Exception:
try:
fig.set_tight_layout(False)
except Exception:
pass
fig.patch.set_facecolor(palette["bg"])
# 根据当前画布像素尺寸动态缩放字体,避免窗口缩小时文字挤压重叠。
font_scale = 1.0
@@ -341,13 +358,12 @@ def plot_accuracy(self: "PQAutomationApp", accuracy_data, test_type):
else:
title = f"{test_type_name} - 色准测试(全 29色 | Gamma {target_gamma}"
title_color = "#F3F5F7" if dark_mode else "#111"
fig.suptitle(
title,
fontsize=max(8, 11 * font_scale),
y=0.975,
fontweight="bold",
color=title_color,
color=palette["fg"],
)
gs = fig.add_gridspec(
@@ -362,6 +378,8 @@ def plot_accuracy(self: "PQAutomationApp", accuracy_data, test_type):
ax_left = fig.add_subplot(gs[0, 0])
ax_uv = fig.add_subplot(gs[0, 1])
ax_judge = fig.add_subplot(gs[1, :])
for ax in (ax_left, ax_uv, ax_judge):
ax.set_facecolor(palette["card_bg"])
# 兼容外部对 self.accuracy_ax 的引用
self.accuracy_ax = ax_judge