首页 > 解决方案 > 在 Julia.Plots 中使用 GR 箭头样式

问题描述

我想在使用 GR 后端的 julia Plots 绘制的绘图中注释一个点。我得到了绘制的箭头

plot([(pos1), (pos2)], line=:arrow)

正如预期的那样,这绘制了一个:simple箭头。但是,我不知道如何获取:filled:closed箭头。我尝试了几种排列:

plt1 = plot([(pos1), (pos2)], line=:arrow, arrow=arrow(:closed))
plt2 = plot([(pos1), (pos2)], line=:arrow, arrow=:closed)

也可以直接调用GR函数

plt3 = plot([(pos1), (pos2)], line=:arrow, arrow_style=arrow(:closed))
plt4 = plot([(pos1), (pos2)], line=:arrow, arrow=arrow_style(:closed))

有没有办法在 Julia.Plots 上切换箭头样式?

标签: juliaannotatearrows

解决方案


你只需要摆脱line = :arrow关键字参数。linein Plots 是一个神奇的参数line = :arrowarrow = :arrow在预处理管道期间转换为内部,覆盖提供的箭头属性。

plot(rand(2), rand(2), arrow = :closed, lims = (0, 1))

在此处输入图像描述


推荐阅读