在 Vega Lite 中,我试图将我的图例与该图表的中间对齐。我需要类似的东西anchor
图例的参数,但我只能找到titleAnchor
.
带图例的图表 https://i.stack.imgur.com/ETiFs.png
"legend": {
"title": "Signed NDA",
"orient": "bottom",
"titleAnchor": "middle"
}
这就是我的传奇现在的样子。有人知道怎么做吗?
这实际上在 Vega 5.0 中是可能的,图例布局属性 https://vega.github.io/vega/docs/config/#legend-layout-properties-50,通过设置anchor
财产给"middle"
,在图例的布局配置中。
提供layout
Vega-Lite 似乎还没有直接支持,但是可以传播layout
从 Vega-Lite 到 Vega 的定义。
按照杰克的回答,在Vega-Lite 编辑器 https://vega.github.io/editor/#/url/vega-lite/N4IgJghgLhIFygK4CcA29zQgegMYWQGcA6AK0IHsA7EAXwBoQBbAgawwAcKBLKqERgFMquCmF4BzeKAAe0kADNug1GAwAJCkUFcA7oOQCQUAJ4dBGAI6IIfbjCjcAbhYYgT8pSrVwQAWW5UQUIAfXNkEIBxCFRUaiNTcysbOwdnV0ZROMMERWVVDAB5ZG4JXgSzC18qCiZeGLo3AAtBUqb+OABmAAZuxl1uMCgm+AAWXszqJSlcoIlhH1AtZT4MACMKKChao1QIEwpEDtANrZ3c21wmrQw6sDAgxtpnoA:
{
"data": {"url": "data/cars.json"},
"mark": "point",
"encoding": {
"x": {"field": "Horsepower", "type": "quantitative"},
"y": {"field": "Miles_per_Gallon", "type": "quantitative"},
"color": {"field": "Origin", "type": "nominal"}
},
"height": 300,
"width": 400,
"config": {
"legend": {"orient": "bottom", "layout": {"bottom": {"anchor": "middle"}}}
}
}
指定config
最后基本上允许您自定义如何orient
"bottom"
应该看看。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)