【问题标题】:How to use markes on a line graph in Observable Plot?如何在 Observable Plot 的折线图上使用标记?
【发布时间】:2022-02-09 16:58:13
【问题描述】:

在使用Observable Plot 时,我偶然发现了API documentation 中的markers section

然而,我不知道如何使它工作。

想象一下我有以下标记:

Plot.line(data, {x: \"timestamp\", y: \"val\", curve: \"natural\"})

如何为这条线上的每个数据点添加标记?我无法从 API 文档中提取该信息(一个例子会很好)。以下版本不起作用

Plot.line(data, {x: \"timestamp\", y: \"val\", curve: \"natural\", marker: true, markerEnd: \"circle\"})
Plot.line(data, {x: \"timestamp\", y: \"val\", curve: \"natural\", marker: \"circle\"}) 

备注:我不是在寻找使用额外 Plot.dot 的解决方案。

备注2:转帖至ObservableHQ forum

    标签: javascript plot data-visualization observablehq observable-plot


    【解决方案1】:

    ObservableHQ forum 收到以下答复:

    标记在 main 中可用仅一周,但尚未推送到 npm 和 Observable。

    如果你现在需要它们,下面是从源代码构建 Plot 的方法:

    git clone https://github.com/observablehq/plot.git
    cd plot
    yarn
    yarn prepublishOnly
    

    然后文件将在 dist/ 文件夹中可用。上传 dist/plot.umd.js 作为文件附件,然后创建一个单元格:

    Plot = require(await FileAttachment(“plot.umd.js”).url())
    

    因此,要么等待新版本发布,要么现在自己构建源代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-02
      • 1970-01-01
      • 2011-03-06
      • 2017-04-04
      • 2017-12-07
      相关资源
      最近更新 更多