如何移除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
相关产品推荐
相关产品推荐

