用 VegaLite.jl 缩放 x 轴和 y 轴
Scaling x axis and y axis with VegaLite.jl
我在 VegaLite.jl
中绘制了一个散点图,但是,x 轴和 y 轴不会像其他绘图包(plots、plotly 等)那样自动缩放
例如,在下面的示例中,绘图从 0 开始 x 轴,而从 125 等值开始更有意义,因为 x 值集中在 150-200 之间。同样的事情也适用于 y 轴。这会导致绘图仅使用右上部分。关于如何缩放 x 轴和 y 轴的任何想法?
using VegaLite
x = Array{Int64}([150,175,200])
y = Array{Int64}([225,250,275])
@vlplot(
:point,
x = x,
y = y
)
您可以添加 scale
规范,如 VegaLite.jl
文档中的 Vega-Lite documentation or demonstrated e.g. here 所述。
例如:
using VegaLite
using DataFrames
data = DataFrame(x = [150,175,200], y = [225,250,275])
data |> @vlplot(
:point,
x = {:x, scale = {zero = false}}, # Auto scale, without enforcing that zero be in the domain
y = {:y, scale = {domain = (200, 300)}}, # Explicit domain
)
我在 VegaLite.jl
中绘制了一个散点图,但是,x 轴和 y 轴不会像其他绘图包(plots、plotly 等)那样自动缩放
例如,在下面的示例中,绘图从 0 开始 x 轴,而从 125 等值开始更有意义,因为 x 值集中在 150-200 之间。同样的事情也适用于 y 轴。这会导致绘图仅使用右上部分。关于如何缩放 x 轴和 y 轴的任何想法?
using VegaLite
x = Array{Int64}([150,175,200])
y = Array{Int64}([225,250,275])
@vlplot(
:point,
x = x,
y = y
)
您可以添加 scale
规范,如 VegaLite.jl
文档中的 Vega-Lite documentation or demonstrated e.g. here 所述。
例如:
using VegaLite
using DataFrames
data = DataFrame(x = [150,175,200], y = [225,250,275])
data |> @vlplot(
:point,
x = {:x, scale = {zero = false}}, # Auto scale, without enforcing that zero be in the domain
y = {:y, scale = {domain = (200, 300)}}, # Explicit domain
)