【问题标题】:Is it possible to write Latex on Vega-Lite?可以在 Vega-Lite 上写 Latex 吗?
【发布时间】:2020-12-19 13:03:04
【问题描述】:

我想使用带有 Latex 表达式的“文本”标记并使用 Vega-Lite 绘制它。这可能吗?例如:

data = {x:[0,1,2,3],y:[0,1,2,3],t=["x^0","x^1","x^2","x^3"]}
{
  "data":data
  }],
  "mark": "text",
  "encoding": {
    "x": {"field": "x", "type": "quantitative"},
    "y": {"field": "y", "type": "quantitative"},
    "text": {"field": "t", "type": "nominal"}
  }
}

【问题讨论】:

    标签: plot latex visualization vega-lite


    【解决方案1】:

    不,Vega-Lite 规范不支持 LaTeX 数学(相关功能请求是 here)。但是对于示例中的简单数学表达式,您通常可以使用 unicode 文本来表示它们:

    {
      "data":{
        "values": [
          {"x": 0, "t": "x⁰"},
          {"x": 1, "t": "x¹"},
          {"x": 2, "t": "x²"},
          {"x": 3, "t": "x³"}
        ]
      },
      "mark": "text",
      "encoding": {
        "x": {"field": "x", "type": "quantitative"},
        "y": {"field": "x", "type": "quantitative"},
        "text": {"field": "t", "type": "nominal"}
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2020-10-08
      • 2020-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-09
      • 1970-01-01
      • 2020-04-22
      • 1970-01-01
      相关资源
      最近更新 更多