【问题标题】:Vega-Lite - Error in the scales of circles and linesVega-Lite - 圆和线的比例错误
【发布时间】:2020-11-16 18:32:45
【问题描述】:

我正在尝试使用 Vega-Lite 绘制类似于图的绘图,其中节点通过边连接到其他节点。节点的大小根据变量而变化,而边的宽度也不同。 节点信息与边信息存储在不同的数据集中。

问题是,一旦我尝试将所有内容绘制在一起(“节点”+“边缘”),Vega-Lite 会将节点的大小标记为非常小(几乎不可见)。如果我的边缘图不使用“大小”,一切都会正常。

这是我正在做的一个例子(注意符号与原生 Vega-Lite 有点不同,因为我在 Julia 上编程):

v1 = @vlplot(
    mark={:circle,opacity=1},
    x={μ[:,1],type="quantitative",axis=nothing},
    y={μ[:,2],type="quantitative",axis=nothing},
    width=600,
    height=400,
    size={μ_n,legend=nothing,type="q"})
v2 = @vlplot(
    mark={"type"=:circle,color="red",opacity=1},
    x={ν[:,1],type="quantitative",axis=nothing},
    y={ν[:,2],type="quantitative",axis=nothing},
    width=600,
    height=400,
    size={ν_m,legend=nothing,type="q"})

然后,当我为边缘创建可视化并将所有内容绘制在一起时:

v3 = @vlplot(
    mark={"type"=:line,color="black",clip=false},
    data = df,
    encoding={
    x={"edges_x:q",axis=nothing},
    y={"edges_y:q",axis=nothing},
    opacity={"ew:q",legend=nothing},
    size={"ew:q",scale={range=[0,2]},legend=nothing},
    detail={"pe:o"}},
    width=600,
    height=400
)
@vlplot(view={stroke=nothing})+v3+v2+v1

关于为什么会发生这种情况以及如何解决它的任何想法? (注意,“scale”属性不是原因。即使我删除它,问题仍然存在)。

【问题讨论】:

    标签: visualization scale vega-lite


    【解决方案1】:

    在渲染复合图表时,Vega-Lite 默认使用共享比例(参见https://vega.github.io/vega-lite/docs/resolve.html):看起来当您的size 比例在折线图和圆图之间共享时,会导致结果不佳。

    我不熟悉 VegaLite.jl 语法,但您希望在顶级图表上的 JSON 规范是:

     "resolve": {"scale": {"size": "independent"}}
    

    【讨论】:

      猜你喜欢
      • 2020-08-13
      • 2018-01-06
      • 1970-01-01
      • 2021-01-23
      • 2020-03-19
      • 1970-01-01
      • 2019-06-02
      • 2020-06-17
      • 2020-12-06
      相关资源
      最近更新 更多