我从索引上画了一条曲线
{
"$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"}
}
}
这是可能的,并使其成为带有图例的虚线,并显示名称为“基本模型”,“ RF模型”
答案 0 :(得分:1)
是的,可以使用Layered Views。
我将使用Line Chart example来修改并添加另一条也用虚线表示的行。 原始图表: 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
属性来实现。请参见以下示例:Line chart with varying stroke dash