You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Stata中twoway connected图两项修改需求求助

Stata twoway connected 图问题解决方案

问题1:背景色无法改为白色

原代码里的graphregion(color(white))只设置了整个图表的外围区域背景,每个子图的绘图区域、子图之间的分隔区域还是默认浅蓝色。需要补充两处设置:

  • 加plotregion(color(white)):把每个子图内部的绘图区域背景改成白色
  • 在by()选项里添加graphregion(color(white)):将子图之间的空白区域设置为白色

问题2:注释放在整个图表底部

用note()时,by()会自动把注释加到每个子图下方;要把注释放到整个图表底部(原“Graphs by car type”的位置),得换成caption()选项。同时可以通过by()的note("")参数清除默认的“Graphs by car type”提示文本。

修正后的完整代码

sysuse auto, clear
twoway (connected price mpg) (connected headroom mpg), by(foreign, graphregion(color(white)) note("")) ///
       legend(order(1 "AAA" 2 "BBB")) ///
       graphregion(color(white)) ///
       plotregion(color(white)) ///
       xtitle(Date) ytitle("Dummy Chart") ///
       caption("Footnote 1" "Footnote 2")

关键修改说明

  • by(foreign, graphregion(color(white)) note("")):设置子图间区域为白色,同时清除默认的子图注释文本
  • plotregion(color(white)):将每个子图的内部绘图背景改为白色
  • caption("Footnote 1" "Footnote 2"):把注释放在整个图表的底部位置

内容的提问来源于stack exchange,提问作者daviddupont

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 09:47:04