Engee 文档

雨滴

该页面正在翻译中。

rainclouds!(ax, category_labels, data_array; plot_boxplots=true, plot_clouds=true, kwargs...)

绘制小提琴(/直方图),箱线图和单个数据点,每个数据点之间有适当的间距。

论点

  • 斧头,斧头:轴用来放置所有这些图。

  • 分类_标签:典型 向量{String} 每个元素都有一个标签 数据阵列

  • 数据阵列:典型 向量{Float64} 用于表示要绘制的数据点。

关键字

绘图类型

绘图类型别名 雨滴 功能是 雨滴.

"雨云"图是小提琴图、箱形图和散点图的组合。 这三个组合在一起可以成为一个吸引人和信息丰富的视觉,特别是对于大型n数据集。 </无翻译>

using CairoMakie
using Random
using Makie: rand_localized

####
#### Below is used for testing the plotting functionality.
####

function mockup_distribution(N)
    all_possible_labels = ["Single Mode", "Double Mode", "Random Exp", "Uniform"]
    category_type = rand(all_possible_labels)

    if category_type == "Single Mode"
        random_mean = rand_localized(0, 8)
        random_spread_coef = rand_localized(0.3, 1)
        data_points = random_spread_coef*randn(N) .+ random_mean

    elseif category_type == "Double Mode"
        random_mean = rand_localized(0, 8)
        random_spread_coef = rand_localized(0.3, 1)
        data_points = random_spread_coef*randn(Int(round(N/2.0))) .+ random_mean

        random_mean = rand_localized(0, 8)
        random_spread_coef = rand_localized(0.3, 1)
        data_points = vcat(data_points, random_spread_coef*randn(Int(round(N/2.0))) .+ random_mean)

    elseif category_type == "Random Exp"
        data_points = randexp(N)

    elseif category_type == "Uniform"
        min = rand_localized(0, 4)
        max = min + rand_localized(0.5, 4)
        data_points = [rand_localized(min, max) for _ in 1:N]

    else
        error("Unidentified category.")
    end

    return data_points
end

function mockup_categories_and_data_array(num_categories; N = 500)
    category_labels = String[]
    data_array = Float64[]

    for category_label in string.(('A':'Z')[1:min(num_categories, end)])
        data_points = mockup_distribution(N)

        append!(category_labels, fill(category_label, N))
        append!(data_array, data_points)
    end
    return category_labels, data_array
end

category_labels, data_array = mockup_categories_and_data_array(3)

colors = Makie.wong_colors()
rainclouds(category_labels, data_array;
    axis = (; xlabel = "Categories of Distributions", ylabel = "Samples", title = "My Title"),
    plot_boxplots = false, cloud_width=0.5, clouds=hist, hist_bins=50,
    color = colors[indexin(category_labels, unique(category_labels))])
3cc6a3c

</无翻译>

rainclouds(category_labels, data_array;
    axis = (; ylabel = "Categories of Distributions",
    xlabel = "Samples", title = "My Title"),
    orientation = :horizontal,
    plot_boxplots = true, cloud_width=0.5, clouds=hist,
    color = colors[indexin(category_labels, unique(category_labels))])
db65c47

</无翻译>

rainclouds(category_labels, data_array;
    axis = (;
        xlabel = "Categories of Distributions",
        ylabel = "Samples",
        title = "My Title"
    ),
    plot_boxplots = true, cloud_width=0.5, clouds=hist,
    color = colors[indexin(category_labels, unique(category_labels))])
4afccc4

</无翻译>

rainclouds(category_labels, data_array;
    axis = (;
        xlabel = "Categories of Distributions",
        ylabel = "Samples",
        title = "My Title"
    ),
    plot_boxplots = true, cloud_width=0.5, side = :right,
    violin_limits = extrema, color = colors[indexin(category_labels, unique(category_labels))])
a738c3b

</无翻译>

rainclouds(category_labels, data_array;
    axis = (;
        xlabel = "Categories of Distributions",
        ylabel = "Samples",
        title = "My Title",
    ),
    plot_boxplots = true, cloud_width=0.5, side = :right,
    color = colors[indexin(category_labels, unique(category_labels))])
5dcf567

</无翻译>

more_category_labels, more_data_array = mockup_categories_and_data_array(6)

rainclouds(more_category_labels, more_data_array;
    axis = (;
        xlabel = "Categories of Distributions",
        ylabel = "Samples",
        title = "My Title",
    ),
    plot_boxplots = true, cloud_width=0.5,
    color = colors[indexin(more_category_labels, unique(more_category_labels))])
af9c648

</无翻译>

category_labels, data_array = mockup_categories_and_data_array(6)
rainclouds(category_labels, data_array;
    axis = (;
        xlabel = "Categories of Distributions",
        ylabel = "Samples",
        title = "My Title",
    ),
    plot_boxplots = true, cloud_width=0.5,
    color = colors[indexin(category_labels, unique(category_labels))])
642bdb7

其中4个,在3个左右分布之间的例子,有和没有箱形图 </无翻译>

fig = Figure(size = (800*2, 600*5))
colors = [Makie.wong_colors(); Makie.wong_colors()]

category_labels, data_array = mockup_categories_and_data_array(3)
rainclouds!(
    Axis(fig[1, 1], title = "Left Side, with Box Plot"),
    category_labels, data_array;
    side = :left,
    plot_boxplots = true,
    color = colors[indexin(category_labels, unique(category_labels))])

rainclouds!(
    Axis(fig[2, 1], title = "Left Side, without Box Plot"),
    category_labels, data_array;
    side = :left,
    plot_boxplots = false,
    color = colors[indexin(category_labels, unique(category_labels))])

rainclouds!(
    Axis(fig[1, 2], title = "Right Side, with Box Plot"),
    category_labels, data_array;
    side = :right,
    plot_boxplots = true,
    color = colors[indexin(category_labels, unique(category_labels))])

rainclouds!(
    Axis(fig[2, 2], title = "Right Side, without Box Plot"),
    category_labels, data_array;
    side = :right,
    plot_boxplots = false,
    color = colors[indexin(category_labels, unique(category_labels))])

# Plots with more categories
# dist_between_categories (0.6, 1.0)
# with and without clouds

category_labels, data_array = mockup_categories_and_data_array(12)
rainclouds!(
    Axis(fig[3, 1:2], title = "More categories. Default spacing."),
    category_labels, data_array;
    plot_boxplots = true,
    gap = 1.0,
    color = colors[indexin(category_labels, unique(category_labels))])

rainclouds!(
    Axis(fig[4, 1:2], title = "More categories. Adjust space. (smaller cloud widths and smaller category distances)"),
    category_labels, data_array;
    plot_boxplots = true,
    cloud_width = 0.3,
    gap = 0.5,
    color = colors[indexin(category_labels, unique(category_labels))])

rainclouds!(
    Axis(fig[5, 1:2], title = "More categories. Adjust space. No clouds."),
    category_labels, data_array;
    plot_boxplots = true,
    clouds = nothing,
    gap = 0.5,
    color = colors[indexin(category_labels, unique(category_labels))])

supertitle = Label(fig[0, :], "Cloud Plot Testing (Scatter, Violin, Boxplot)", fontsize=30)
fig
b756efe

属性

箱线图_推

默认值为 0.075

确定在以下情况下,箱线图应与中心线的距离 中心_箱线图错误. 这是用于重新输入箱线图的值。

箱线图_宽度

默认值为 0.1

类别轴上箱线图的宽度。

中心_箱线图

默认值为 真的

是否在类别上居中箱线图。

云宽度

默认值为 0.75

确定小提琴情节的大小. 对应于 阔度 关键字arg in 小提琴.

云彩

默认值为 小提琴

[violin, hist, nothing] 如何将云图显示为小提琴图或直方图图,或者根本不显示。

颜色

默认值为 @继承patchcolor

一个单一的颜色,或一个颜色向量,每个点一个。

周期

默认值为 [:颜色=>:补丁颜色]

没有可用的文档。

道奇

默认值为 自动的

的向量 整数 (数据长度)分组变量以在同一x位置创建多个并排框

dodge_gap

默认值为 0.01

闪避盒之间的间距。

差距

默认值为 0.2

主轴上元素之间的距离(取决于 方向感).

组织/组织

默认值为 30

如果 云=hist,这将箱数向下传递给直方图调用。

jitter_width

默认值为 0.05

以类别x轴绝对项确定散点图条的宽度。

标记大小

默认值为 2.0

用于散点图的标记的大小。

n_dodge的

默认值为 自动的

要闪避的类别数(默认为 最大值(闪避))

方向感

默认值为 :垂直

雨滴的方向(:垂直:水平)

绘图_箱线图

默认值为 真的

是否显示箱线图来汇总数据的分布。

show_boxplot_outliers

默认值为 错误

将箱线图中的异常值显示为点(与散点图配对时通常会令人困惑,因此默认是不显示它们)

[医]显示

默认值为 真的

确定箱线图中是否有中值的线。

侧面

默认值为 :左

可以取值 :左, :对,确定小提琴图相对于散点的位置

侧推/侧推

默认值为 自动的

散点图特定。 默认值为0.02如果 绘图_箱线图 是真的,否则 0.075 违约。

斯特罗克威德斯

默认值为 1.0

确定箱线图轮廓的笔划宽度。

小提琴-小提琴

默认值为 (-Inf,Inf)

指定要修剪的值 小提琴. 可以是一个 元组 或一个 功能 (例如 datalimits=极值)

晶须宽度

默认值为 0.5

箱线图中Q1、Q3晶须的宽度。 值作为所述 箱线图_宽度.