Skip to content

Commit 3bf7a49

Browse files
author
Tonny@Home
committed
fix: translate plotting labels to English and remove redundant Chinese font settings
1 parent 52e4c69 commit 3bf7a49

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

quantpits/scripts/plot_model_opinions.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
except ImportError:
2121
pass
2222

23-
# 支持中文显示
24-
plt.rcParams['font.sans-serif'] = ['SimHei', 'WenQuanYi Micro Hei', 'Microsoft YaHei']
25-
plt.rcParams['axes.unicode_minus'] = False
23+
# Support English labels
24+
# plt.rcParams['font.sans-serif'] = ['SimHei', 'WenQuanYi Micro Hei', 'Microsoft YaHei']
25+
# plt.rcParams['axes.unicode_minus'] = False
2626

2727
def main():
2828
parser = argparse.ArgumentParser(description="绘制 model_opinions 排名折线图")
@@ -79,11 +79,11 @@ def main():
7979
# 调整 X 轴标签角度,防止重叠
8080
plt.xticks(rotation=30, ha='right')
8181

82-
plt.ylabel('模型预测排名 (数字越小越靠前)')
83-
plt.title(f'模型预测排名对比 - {os.path.basename(csv_file)}')
82+
plt.ylabel('Model Prediction Rank (Smaller is Better)')
83+
plt.title(f'Model Prediction Rank Comparison - {os.path.basename(csv_file)}')
8484

85-
# 将图例画在外面
86-
plt.legend(bbox_to_anchor=(1.02, 1), loc='upper left', borderaxespad=0., title="标的 (Instrument)")
85+
# Legend outside
86+
plt.legend(bbox_to_anchor=(1.02, 1), loc='upper left', borderaxespad=0., title="Instrument")
8787

8888
plt.tight_layout()
8989

ui/dashboard.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,14 @@ def render_macro_performance(port_a, returns, market):
8888
if not bench_returns.eq(0).all():
8989
fig1.add_trace(go.Scatter(x=bench_cum.index, y=bench_cum.values, mode='lines', name=f'Benchmark ({market_col})', line=dict(color='orange', width=2)))
9090

91-
fig1.update_layout(title="Cumulative Returns on Log Scale", yaxis_type="log", yaxis_title="Cumulative Return (Log)", xaxis_title="Date", template="plotly_white")
91+
fig1.update_layout(
92+
title="Cumulative Returns on Log Scale",
93+
yaxis_type="log",
94+
yaxis_title="Cumulative Return (Log)",
95+
xaxis_title="Date",
96+
template="plotly_white",
97+
legend_title_text="Legend"
98+
)
9299
st.plotly_chart(fig1, use_container_width=True)
93100

94101
# 2. Underwater Plot
@@ -140,6 +147,12 @@ def render_micro_execution(exec_a):
140147
x='MAE',
141148
y='MFE',
142149
color='Is_Profitable_Intraday',
150+
labels={
151+
'证券代码': 'Instrument',
152+
'成交日期': 'Date',
153+
'成交价格': 'Execution Price',
154+
'Is_Profitable_Intraday': 'Status'
155+
},
143156
hover_data=['证券代码', '成交日期', '成交价格', 'Trade_Type'],
144157
title="MFE vs. MAE Scatter (Intraday Path Dependency)",
145158
color_discrete_map={'Profitable': 'green', 'Loss': 'red'}
@@ -302,7 +315,11 @@ def top1_conc(g):
302315
fig1.add_trace(go.Scatter(x=daily_count.index, y=daily_count.values, name="Holdings Count", mode="lines", line=dict(color="blue")), secondary_y=False)
303316
fig1.add_trace(go.Scatter(x=concentration.index, y=concentration.values, name="Top1 Concentration", mode="lines", line=dict(color="red")), secondary_y=True)
304317

305-
fig1.update_layout(title="Holdings Count & Concentration Over Time", template="plotly_white")
318+
fig1.update_layout(
319+
title="Holdings Count & Concentration Over Time",
320+
template="plotly_white",
321+
legend_title_text="Metric"
322+
)
306323
fig1.update_yaxes(title_text="Count", secondary_y=False)
307324
fig1.update_yaxes(title_text="Concentration", tickformat=".1%", secondary_y=True)
308325
st.plotly_chart(fig1, use_container_width=True)

0 commit comments

Comments
 (0)