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

如何通过VBA隐藏Excel箱形图(箱须图)中的内部数据点?

Excel箱形图(箱须图)隐藏内部数据点VBA解决方案

Excel箱须图的内部数据点控制属性属于箱形图系列的专属属性,宏录制器不支持捕获该类操作,直接为目标系列设置ShowInnerPoints = False即可实现隐藏需求。

以下是修改后的完整可运行代码,已新增隐藏内部数据点的逻辑:

Set shp = wksData.Shapes.AddChart2(406, xlBoxwhisker, intLeft, intTop, intGraphWidth, intGraphHeight)
With shp.Chart
    .FullSeriesCollection(1).Name = strLegend
    .FullSeriesCollection(1).XValues = wksData.Range(wksData.Cells(lngRowA, xPosAxis), wksData.Cells(lngRowZ, xPosAxis))
    .FullSeriesCollection(1).Format.Line.ForeColor.RGB = RGB(intR, intG, intB)
    .FullSeriesCollection(1).Format.Fill.ForeColor.RGB = RGB(intR, intG, intB)
    .FullSeriesCollection(1).Format.Fill.Transparency = 0.8
    ' 新增代码:隐藏内部数据点
    .FullSeriesCollection(1).ShowInnerPoints = False
    .ChartGroups(1).GapWidth = 20
    .Parent.Name = "Chart " & strTARGET
    .HasLegend = True
    .Legend.Position = xlLegendPositionBottom
    .HasTitle = True
    .ChartTitle.Text = strTARGET
    .Axes(xlValue).HasTitle = True
    .Axes(xlValue).AxisTitle.Text = "[g/kg_fuel]"
    .Axes(xlValue).HasMajorGridlines = True
    .Axes(xlCategory).HasTitle = True
    .Axes(xlCategory).AxisTitle.Text = strX
    .Axes(xlCategory).HasMajorGridlines = True
End With

你还可以根据需求调整其他箱形图显示属性:

  • 隐藏离群点(超出箱须范围的孤立数据点):FullSeriesCollection(1).ShowOutlierPoints = False
  • 隐藏均值标记:FullSeriesCollection(1).ShowMeanMarkers = False
  • 隐藏均值连线:FullSeriesCollection(1).ShowMeanLine = False
  • 隐藏中位数线:FullSeriesCollection(1).ShowMedianLine = False

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.02 06:18:03