plot - 使用 Julia-Package "Plots"的不对称带状折线图

标签 plot julia gadfly plots.jl

我想出了如何使用包“Gadfly”和以下代码绘制一个带有不对称“丝带”的折线图

x=collect(-10:10);
y=[i^2 for i in -10:10];
ymin = y-5;
ymax = y+10;
using Gadfly
plot(x=x, y=y, ymin=ymin, ymax=ymax, Geom.smooth, Geom.ribbon)

(这在 this question 中有描述。)

enter image description here

现在我想使用“Plots”包的 plot 函数来做同样的事情。有选项 ribbonfillrange (参见 http://plots.readthedocs.io/en/latest/examples/pyplot/#layouts-margins-label-rotation-title-location )但我不知道如何使用它们。是否可以使用“Plots”包创建这样的图?如果可以,如何创建?

最佳答案

在我标记 RecipesBase 和 Plots 的新版本之前,您需要:

Pkg.checkout("Plots")
Pkg.checkout("RecipesBase")

现在要重现您的示例,您可以这样做:

using Plots; pyplot(border=false)
x = -10:10
y = x .^ 2
plot(x, y, ribbon=(5,10), fillalpha=0.2)

plt

ribbon arg 可以有多种形式:

plot(x, y, ribbon = 5)  # both sides are 5
plot(x, y, ribbon = 1:3) # both sides cycle through 1:3
plot(x, y, ribbon = (5, 1:3))  # bottom is 5, top cycles 1:3

关于plot - 使用 Julia-Package "Plots"的不对称带状折线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37701317/

相关文章:

python - 在 Julia 中使用点绘制球体

python - 在python中向散点图添加一个点

algorithm - 如何找到最佳(信息量最大)的绘图限制?

compilation - Julia 中的系统镜像构建

plot - 面板内没有网格线,但 Gadfly 中存在轴刻度 - Julia

r - 自动缩放 Rmarkdown 文档中 ggplot2 的字体大小(等)

julia - Julia 中的对称组 Action

dataframe - 在 Julia 中加入数据帧

methods - Julia:为自定义类型定义方法

graph - 如何在 JULIA 中使用 GADFLY 实现直方图绘制的精度