<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          ggplot2繪制流圖

          共 664字,需瀏覽 2分鐘

           ·

          2022-05-12 22:21

          使用的是ggstream中的blockbusters數據集。

          library(ggstream)

          blockbusters

          該包的geom_stream功能ggstrean允許 在 ggplot2 中創(chuàng)建流圖。

          library(ggstream)
          #?install.packages("ggplot2")
          library(ggplot2)

          ggplot(blockbusters,?aes(x?=?year,?y?=?box_office,?fill?=?genre))?+
          ??geom_stream()

          該包包含一個名為的附加函數geom_stream_label,可用于將標簽添加到流圖的每個區(qū)域。

          ggplot(blockbusters,?aes(x?=?year,?y?=?box_office,?fill?=?genre))?+
          ??geom_stream()?+
          ??geom_stream_label(aes(label?=?genre))

          默認情況下,該geom_stream函數使用"mirror"類型,它圍繞 X 軸對稱地堆疊流。其他替代方案是"ridge",它從 X 軸堆疊,并且"proportional",它使流總和為 1。

          ggplot(blockbusters,?aes(x?=?year,?y?=?box_office,?fill?=?genre))?+
          ??geom_stream(type?=?"ridge")

          scale_fill_manual可以使用或等效函數更改流圖的填充顏色。

          cols?<-?c("#FFB400",?"#FFC740",?"#C20008",?"#FF020D",?"#13AFEF")

          ggplot(blockbusters,?aes(x?=?year,?y?=?box_office,?fill?=?genre))?+
          ??geom_stream()?+
          ??scale_fill_manual(values?=?cols)

          默認情況下,這些區(qū)域沒有邊框,但可以使用函數的color參數添加邊框顏色geom_stream并使用 修改其寬度lwd。

          cols?<-?c("#FFB400",?"#FFC740",?"#C20008",?"#FF020D",?"#13AFEF")

          ggplot(blockbusters,?aes(x?=?year,?y?=?box_office,?fill?=?genre))?+
          ??geom_stream(color?=?1,?lwd?=?0.25)?+
          ??scale_fill_manual(values?=?cols)

          請注意,還可以更改主題以修改圖表的外觀。

          cols?<-?c("#FFB400",?"#FFC740",?"#C20008",?"#FF020D",?"#13AFEF")

          ggplot(blockbusters,?aes(x?=?year,?y?=?box_office,?fill?=?genre))?+
          ??geom_stream(color?=?1,?lwd?=?0.25)?+
          ??scale_fill_manual(values?=?cols)?+
          ??theme_minimal()


          瀏覽 40
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  欧美爱大屌 | 国产女人18毛片水真多18精品 | 久草精品A区 | 先锋成人AV | 黄色录像免费看。 |