vega-lite - 如何在 vega-lite 的折线图中画一条线?
问题描述
我有一条从索引绘制的曲线
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.4.json",
"title": {
"text": "Receiver Operating Characteristics - Area Under Curve",
"anchor": "middle",
"fontSize": 16,
"frame": "group",
"offset": 4
},
"data": {
"url" : {
"%context%": true,
"index": "roccurve_index2",
"body": {
"size":10000,
"_source": ["lr_fpr", "lr_tpr"],
}
}
"format": {"property": "hits.hits"},
},
"mark": {
"type": "line",
"point": true
},
"encoding": {
"x": {"field": "_source.lr_fpr", "type": "quantitative", "title":"False Positive Rate"},
"y": {"field": "_source.lr_tpr", "type": "quantitative", "title":"True Positive Rate"}
}
}
这可能吗,并将其设为带有图例的虚线,显示名称为 Base Model、RF Model
解决方案
是的,可以使用分层视图。
我将使用折线图示例来修改和添加另一条虚线。原图: https ://vega.github.io/editor/#/examples/vega-lite/line
这是修改后的图表,我对直线使用了明确的值:
https://vega.github.io/editor/#/gist/152fbe5f986ba78e422bb3430628f010/spec.json
层解决方案
当您使用分层视图时,您可以在同一个图表和相同的 x 和 y 轴中放置多条线
"layer" : [
{
//mark #1
},
{
//mark #2
}
]
虚线
可以使用strokeDash
属性来实现。请参阅此示例: 具有不同笔划破折号的折线图
推荐阅读
- dbt - 将 dbt 安装到 Windows 失败:- install --ignore-installed
- php - 在 Woocommerce 中删除订单发票 PDF 中的组件/变体
- r - combining words in tm R is not achieving desired result
- flutter - 在颤动中连续显示按钮和列表视图
- javascript - 通过从 JSON 文件执行初始同步来节省 Firebase RTDB 带宽
- keycloak - 无法使用 Apple ID 登录 - Keycloak
- elasticsearch - 如何从弹性搜索中的聚合中排除边缘 n-gram?
- geoserver - 在 Geoserver 中禁用图层预览
- javascript - 如何仅选中和取消选中所有特定手风琴?
- c# - 如何使用 OleDb 获取视图的结构/查询?