【问题标题】:Full panel break for highly skewed ggplot2 histogram高度倾斜的 ggplot2 直方图的全面板中断
【发布时间】:2017-04-02 10:35:31
【问题描述】:

我使用 ggplot2 生成了高度偏斜的直方图。

我想将直方图的 x 轴分成两个面板。一个 x50 以检测任何潜在模式(如果有)。所以第一个面板的 y 轴从 0 到 500000 左右,x 轴从 0 到 50。第二个面板的 y 轴从 0 到 100 左右,x 轴从 50 到 350。

谢谢

【问题讨论】:

    标签: r ggplot2 histogram facet skew


    【解决方案1】:

    只考虑条件:

    ggplot(diamonds, aes(carat)) + geom_histogram() + facet_wrap(~(carat > 3), scale = 'free')
    

    【讨论】:

    • 这很好用!我可以知道如何将每个面板上的标题从 FALSE 更改为 TRUE 吗?
    • 首先创建一个新变量,适当地命名因子级别。例如。 diamonds$my_condition <- factor(diamonds$carat > 3, c(TRUE, FALSE), c('label1', 'label2')); ggplot(....) + ..... + facet_wrap(~my_condition, ......)
    猜你喜欢
    • 2013-10-17
    • 2021-03-29
    • 2013-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-30
    相关资源
    最近更新 更多