如何使用 Plots (Julia) 使 x 轴和 y 轴变粗?

How do I make x and y axes thicker with Plots (Julia)?

如何在 Julia Plots 中使 x 轴和 y 轴的线更粗? 有没有简单的方法可以做到这一点?

MWE:

using Plots

Nx, Ny = 101,101
x = LinRange(0, 100, Nx)
y = LinRange(0, 100, Ny)

foo(x,y; x0=50, y0=50, sigma =1) = exp(- ((x-x0)^2 + (y-y0)^2)/(2*sigma^2)  )
NA = [CartesianIndex()]  # for "newaxis"
Z = foo.(x[:,NA], y[NA,:], sigma=10);

hm = heatmap(x, y, Z, xlabel="x", ylabel="y", c=cgrad(:Blues_9), clim=(0,1))
plot(hm, tickfontsize=10, labelfontsize=14)

导致:

到目前为止我找到的帖子表明这是不可能的:

  1. https://discourse.julialang.org/t/plots-jl-modify-frame-thickness/24258/4
  2. https://github.com/JuliaPlots/Plots.jl/issues/1099

还是这样?

我情节的实际代码要长得多。 我不想在不同的绘图库中重写所有内容。

目前,Plots.jl 中似乎没有坐标轴厚度的属性。

作为解决方法,您可以使用属性 thickness_scaling,这将缩放所有内容的粗细:线、网格线、轴线等。由于您只想更改轴的粗细,您需要缩小其他的。这是您使用 pyplot 后端执行此操作的示例代码。

using Plots
pyplot() # use pyplot backend

Nx, Ny = 101,101
x = LinRange(0, 100, Nx)
y = LinRange(0, 100, Ny)

foo(x,y; x0=50, y0=50, sigma =1) = exp(- ((x-x0)^2 + (y-y0)^2)/(2*sigma^2)  )
NA = [CartesianIndex()]  # for "newaxis"
Z = foo.(x[:,NA], y[NA,:], sigma=10);

hm = heatmap(x, y, Z, xlabel="x", ylabel="y", c=cgrad(:Blues_9), clim=(0,1))
plot(hm, tickfontsize=10, labelfontsize=14) # your previous plot

# here is the plot code that shows the same plot with thicker axes on a new window
# note that GR backend does not support `colorbar_tickfontsize` attribute
plot(hm, thickness_scaling=2, tickfontsize=10/2, labelfontsize=14/2, colorbar_tickfontsize=8/2, reuse=false)

有关绘图属性的更多信息,请参阅 Julia Plots Documentation