julia - 如何将条形图 x 轴上的标签从数字更改为文本?

标签 julia plots.jl

我正在尝试使用 Plots.jl 和 GR 后端制作条形图,想问问如何让 x 轴显示文本标签而不是数字。基本上这就是我正在做的:

using Plots; gr()
data = [1,2,3]
labels = ["one","two","three"]

bar(data, legend=false)

这会产生以下情节:

example bar plot

如何在 x 轴上显示我的标签(“一”、“二”、“三”)而不是“1 2 3”?

谢谢!

最佳答案

答案(感谢 Tom!)是将标签作为 x 值传递(目前只能在开发分支上使用):

Pkg.checkout("Plots","dev")
using Plots
gr()

data = [1,2,3]
labels = ["one","two","three"]

bar(labels, data, legend=false)

关于julia - 如何将条形图 x 轴上的标签从数字更改为文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38348711/

相关文章:

date - 如何使用日期获得周数的正常定义

julia - 在 Julia 中动画化 ODE 的解决方案

julia - 如何在 Plots.jl 中旋转字体

julia - 使用 Plots.jl 对多个绘图进行着色

annotations - 如何在 Julia Plots 中制作 3D 注释

julia - 如何在 .juliarc 文件夹中添加文件夹以在 Julia 中运行程序?

julia - 模拟弹跳球?

visual-studio-code - VSCode Jupyter 扩展 : Can't find new kernel after updating Julia?

loops - 如何在 Julia 文档字符串中缩进?

plot - 如何使用 Plots.jl 缩放字体大小