gpt4 book ai didi

plot - Gadfly 按 x 轴的递增顺序绘制,而不是按存储数组的顺序绘制

转载 作者:行者123 更新时间:2023-12-02 00:59:57 24 4
gpt4 key购买 nike

我正在使用 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))

如何获得与点图完全一样的线图?

最佳答案

参见 Geom.path在 Gadfly 文档中。示例:

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

关于plot - Gadfly 按 x 轴的递增顺序绘制,而不是按存储数组的顺序绘制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51311122/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com