修改calman灰阶点击异常、修改色准结果显示异常
This commit is contained in:
@@ -9,9 +9,12 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from matplotlib.patches import Rectangle
|
||||
from matplotlib.lines import Line2D
|
||||
from matplotlib.patches import Circle
|
||||
|
||||
from app.plots.gamut_background import get_cie1976_background
|
||||
from app.tests.color_accuracy import get_accuracy_color_standards
|
||||
from app.pq.color_patch_map import get_patch_color
|
||||
from app.pq.color_patch_map import get_patch_color_from_xy
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pqAutomationApp import PQAutomationApp
|
||||
@@ -55,14 +58,6 @@ _COLOR_MAP = {
|
||||
}
|
||||
|
||||
|
||||
def _grade_color(delta_e: float) -> str:
|
||||
if delta_e < 3:
|
||||
return "#1FAE45" # 绿
|
||||
if delta_e < 5:
|
||||
return "#E08A00" # 橙
|
||||
return "#D81B1B" # 红
|
||||
|
||||
|
||||
def _xy_to_uv(x: float, y: float):
|
||||
"""CIE 1931 xy → CIE 1976 u'v'"""
|
||||
denom = -2.0 * x + 12.0 * y + 3.0
|
||||
@@ -76,7 +71,7 @@ def _xy_to_uv(x: float, y: float):
|
||||
# ============================================================
|
||||
|
||||
def _draw_left_panel(ax, color_patches, delta_e_values, font_scale=1.0, dark_mode=False):
|
||||
"""左侧仅保留大条形图。"""
|
||||
"""左侧仅保留大条形图"""
|
||||
ax.clear()
|
||||
|
||||
n = len(color_patches)
|
||||
@@ -86,15 +81,14 @@ def _draw_left_panel(ax, color_patches, delta_e_values, font_scale=1.0, dark_mod
|
||||
|
||||
y_pos = list(range(n))
|
||||
bar_colors = [_COLOR_MAP.get(name, "#888888") for name in color_patches]
|
||||
edge_colors = [_grade_color(dE) for dE in delta_e_values]
|
||||
|
||||
ax.barh(
|
||||
y_pos,
|
||||
delta_e_values,
|
||||
height=0.72,
|
||||
color=bar_colors,
|
||||
edgecolor=edge_colors,
|
||||
linewidth=1.0,
|
||||
edgecolor="#202020",
|
||||
linewidth=0.5,
|
||||
zorder=3,
|
||||
)
|
||||
|
||||
@@ -129,9 +123,12 @@ def _draw_uv_diagram(ax, color_patches, measurements, standards, font_scale=1.0,
|
||||
bg, bbox = get_cie1976_background()
|
||||
xmin, xmax, ymin, ymax = bbox
|
||||
ax.imshow(
|
||||
bg, extent=(xmin, xmax, ymin, ymax),
|
||||
origin="upper", interpolation="bicubic",
|
||||
zorder=0, aspect="auto",
|
||||
bg,
|
||||
extent=(xmin, xmax, ymin, ymax),
|
||||
origin="lower",
|
||||
interpolation="bicubic",
|
||||
zorder=0,
|
||||
aspect="auto",
|
||||
)
|
||||
ax.set_xlim(xmin, xmax)
|
||||
ax.set_ylim(ymin, ymax)
|
||||
@@ -145,73 +142,122 @@ def _draw_uv_diagram(ax, color_patches, measurements, standards, font_scale=1.0,
|
||||
legend_label_color = "#FFF" if dark_mode else "#111"
|
||||
legend_bg = "#111" if dark_mode else "#FFFFFF"
|
||||
legend_edge = "#FFF" if dark_mode else "#333"
|
||||
outer_edge = "#FFFFFF" if dark_mode else "#333333"
|
||||
outer_edge = "#FFFFFF" if dark_mode else "#222222"
|
||||
|
||||
ax.set_facecolor("#000" if dark_mode else "#FFFFFF")
|
||||
ax.set_aspect("equal", adjustable="box")
|
||||
ax.set_title("CIE 1976 u'v'", fontsize=max(8, 11 * font_scale), fontweight="bold",
|
||||
color=text_color, pad=4)
|
||||
|
||||
ax.set_title(
|
||||
"CIE 1976 u'v'",
|
||||
fontsize=max(8, 11 * font_scale),
|
||||
fontweight="bold",
|
||||
color=text_color,
|
||||
pad=4,
|
||||
)
|
||||
|
||||
ax.set_xlabel("u'", fontsize=max(7, 9 * font_scale), color=sub_text_color, labelpad=1)
|
||||
ax.set_ylabel("v'", fontsize=max(7, 9 * font_scale), color=sub_text_color, labelpad=1)
|
||||
|
||||
ax.tick_params(axis="both", labelsize=max(6, 8 * font_scale), colors=tick_color)
|
||||
|
||||
for sp in ax.spines.values():
|
||||
sp.set_color(outer_edge)
|
||||
sp.set_linewidth(0.9)
|
||||
|
||||
for name, meas in zip(color_patches, measurements):
|
||||
|
||||
if meas is None or len(meas) < 2:
|
||||
continue
|
||||
|
||||
mx, my = meas[0], meas[1]
|
||||
sxy = standards.get(name)
|
||||
|
||||
if sxy is None:
|
||||
continue
|
||||
|
||||
sx, sy = sxy
|
||||
|
||||
m_u, m_v = _xy_to_uv(mx, my)
|
||||
s_u, s_v = _xy_to_uv(sx, sy)
|
||||
|
||||
face = _COLOR_MAP.get(name, "#FFFFFF")
|
||||
# face = get_patch_color_from_xy(name, (sx, sy)).strip().upper()
|
||||
face = _COLOR_MAP.get(name, "#888888")
|
||||
print(name, face)
|
||||
|
||||
# 目标点:仅空心方框(不填充标准颜色)
|
||||
# 目标点(Target) 空心方框
|
||||
ax.scatter(
|
||||
[s_u], [s_v],
|
||||
s=56, marker="s",
|
||||
facecolors="none", edgecolors=outer_edge,
|
||||
linewidths=1.25, zorder=18,
|
||||
s_u,
|
||||
s_v,
|
||||
s=90,
|
||||
marker="s",
|
||||
facecolors="none",
|
||||
edgecolors=outer_edge,
|
||||
linewidths=1.6,
|
||||
zorder=18,
|
||||
)
|
||||
# 实测点:白色外圈 + 内层圆点
|
||||
|
||||
# 实测点(Actual) 彩色实心 + 白色描边
|
||||
ax.scatter(
|
||||
[m_u], [m_v],
|
||||
s=52, marker="o",
|
||||
facecolors="none", edgecolors=outer_edge,
|
||||
linewidths=1.0, zorder=19,
|
||||
)
|
||||
ax.scatter(
|
||||
[m_u], [m_v],
|
||||
s=24, marker="o",
|
||||
facecolors=face, edgecolors="#111111",
|
||||
linewidths=0.85, zorder=20,
|
||||
[m_u],
|
||||
[m_v],
|
||||
s=80,
|
||||
marker="o",
|
||||
color=face,
|
||||
edgecolors=outer_edge,
|
||||
linewidths=1.2,
|
||||
zorder=20,
|
||||
)
|
||||
|
||||
# # Δu'v' 偏差连线
|
||||
# ax.plot(
|
||||
# [s_u, m_u],
|
||||
# [s_v, m_v],
|
||||
# color=face,
|
||||
# linewidth=1.0,
|
||||
# alpha=0.8,
|
||||
# zorder=15,
|
||||
# )
|
||||
|
||||
legend_handles = [
|
||||
Line2D([0], [0], marker="s", linestyle="none",
|
||||
markerfacecolor="#CCCCCC", markeredgecolor=outer_edge,
|
||||
markersize=7, label="目标 (Target)"),
|
||||
Line2D([0], [0], marker="o", linestyle="none",
|
||||
markerfacecolor="#CCCCCC", markeredgecolor="#000000",
|
||||
markersize=7, label="实测 (Actual)"),
|
||||
Line2D(
|
||||
[0],
|
||||
[0],
|
||||
marker="s",
|
||||
linestyle="none",
|
||||
markerfacecolor="none",
|
||||
markeredgecolor=outer_edge,
|
||||
markersize=9,
|
||||
markeredgewidth=1.4,
|
||||
label="目标 (Target)",
|
||||
),
|
||||
Line2D(
|
||||
[0],
|
||||
[0],
|
||||
marker="o",
|
||||
linestyle="none",
|
||||
markerfacecolor="#AAAAAA",
|
||||
markeredgecolor=outer_edge,
|
||||
markersize=9,
|
||||
markeredgewidth=1.2,
|
||||
label="实测 (Actual)",
|
||||
),
|
||||
]
|
||||
|
||||
leg = ax.legend(
|
||||
handles=legend_handles,
|
||||
loc="lower right", fontsize=max(6, 8 * font_scale),
|
||||
framealpha=0.88, labelcolor=legend_label_color,
|
||||
loc="lower right",
|
||||
fontsize=max(6, 8 * font_scale),
|
||||
framealpha=0.9,
|
||||
labelcolor=legend_label_color,
|
||||
)
|
||||
if leg is not None:
|
||||
|
||||
if leg:
|
||||
leg.get_frame().set_facecolor(legend_bg)
|
||||
leg.get_frame().set_edgecolor(legend_edge)
|
||||
leg.set_zorder(50)
|
||||
|
||||
|
||||
|
||||
def _draw_result_judgement(ax, accuracy_data, font_scale=1.0, dark_mode=False):
|
||||
"""底部结果条"""
|
||||
ax.clear()
|
||||
@@ -353,8 +399,11 @@ def plot_accuracy(self: "PQAutomationApp", accuracy_data, test_type):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.accuracy_canvas.draw()
|
||||
# Select the tab first so the canvas is visible and winfo_width/height
|
||||
# return real pixel dimensions before the figure is rendered.
|
||||
self.chart_notebook.select(self.accuracy_chart_frame)
|
||||
self.accuracy_canvas.get_tk_widget().update_idletasks()
|
||||
self.accuracy_canvas.draw()
|
||||
|
||||
|
||||
class PlotAccuracyMixin:
|
||||
|
||||
Reference in New Issue
Block a user