Gadfly图按x轴的升序排列,而不是按存储数组的顺序排列

时间:2018-07-12 17:08:16

标签: plot julia gadfly

我正在使用Julia 0.6中的Gadfly从数组中绘制一些参数。

这是我使用Geom.point时的输出。我期望在使用Geom.line时,点将按照此图连接,因为数组中的点是按此顺序存储的。

enter image description here

但是当我使用Geom.line时,我得到了:

enter image description here

似乎Gadfly以x轴值的升序连接点,而与存储在数组中的顺序无关。我在matlab中没有得到这种行为。我想知道补救办法是什么。

这是仅一个参数(绿线)的代码段。为了方便起见,我减少了要点:

x_axis = [22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 24.0, 30.0, 30.0, 30.0, 3.0]
y_axis = [-48, -44, -40, -36, -32, -28, -24, -20, -16,-12, -8, -4, 0]


fricPlot = plot(x = x_axis, y = y_axis, 
Theme(default_color=colorant"green"), Geom.point,
            Guide.xlabel("Scaled (a-b)/ Stress value"),
            Guide.ylabel("Depth (m)"),
            Guide.title("Rate and state friction/Stress"),
            Coord.Cartesian(ymin=-24))

如何获取与点图完全相似的线图?

1 个答案:

答案 0 :(得分:2)

请参阅Gadfly文档中的Geom.path。示例:

t = 0:0.2:8pi
plot(x=t.*cos.(t), y=t.*sin.(t), Geom.path)