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

如何移除ObservableHQ分面柱状图的X轴刻度?

移除Observable Plot分面柱状图的X轴刻度

要移除分面柱状图中冗余的X轴刻度,只需在Plot.plot()的配置对象中添加X轴的自定义设置即可,具体有两种实现方式:

方式一:完全移除X轴(含刻度、标签)

直接将X轴的axis设为null,彻底隐藏整个X轴:

Plot.plot({
  marginLeft: 10,
  marginRight: 10,
  label: null,
  y: { padding: 0, label: "Channels (Log_2)" },
  x: { axis: null }, // 移除整个X轴
  color: {
    legend: true,
  },
  marks: [
    Plot.barY(processed_data, {
      fx: "layer",
      x: "concept",
      y: "channel",
      fill: "concept",
      inset: 0.5,
    }),
    Plot.ruleX([0])
  ],
});

方式二:仅隐藏刻度(保留轴线条)

如果需要保留X轴的线条,只是隐藏刻度文本和标记,可以设置ticks为空数组、tickFormat为空字符串:

Plot.plot({
  marginLeft: 10,
  marginRight: 10,
  label: null,
  y: { padding: 0, label: "Channels (Log_2)" },
  x: { ticks: [], tickFormat: "" }, // 仅隐藏刻度
  color: {
    legend: true,
  },
  marks: [
    Plot.barY(processed_data, {
      fx: "layer",
      x: "concept",
      y: "channel",
      fill: "concept",
      inset: 0.5,
    }),
    Plot.ruleX([0])
  ],
});

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 05:44:54