<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>【beeswarm】タグの記事一覧｜ドクターフント(Dr. Hund)</title>
	<atom:link href="https://brain-storm.space/tag/beeswarm/feed/" rel="self" type="application/rss+xml" />
	<link>https://brain-storm.space</link>
	<description>脳や研究について発信するブログです。This site is for research and statistics.</description>
	<lastBuildDate>Wed, 01 Mar 2023 13:49:10 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2</generator>

<image>
	<url>https://brain-storm.space/wp-content/uploads/2021/04/cropped-3d0209af428738b78799159b4ce75ad9-32x32.png</url>
	<title>【beeswarm】タグの記事一覧｜ドクターフント(Dr. Hund)</title>
	<link>https://brain-storm.space</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【R超初心者向け】beeswarmでdotplotを箱ひげ図の上にのせる方法!</title>
		<link>https://brain-storm.space/beeswarm_r/698/</link>
					<comments>https://brain-storm.space/beeswarm_r/698/#respond</comments>
		
		<dc:creator><![CDATA[brainblog]]></dc:creator>
		<pubDate>Thu, 20 May 2021 08:25:47 +0000</pubDate>
				<category><![CDATA[論文作成・統計]]></category>
		<category><![CDATA[beeswarm]]></category>
		<category><![CDATA[dotplot]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[箱ひげ図]]></category>
		<guid isPermaLink="false">https://brain-storm.space/?p=698</guid>

					<description><![CDATA[ggplot2を使わずbeeswarmをつかったドットプロットをわかりやすく説明しました。とても簡単ですが、魅力的な図ができます。 これは私がまだRを触ったことがなかった時、自分が必要に迫られて短時間でドットプロットを書]]></description>
										<content:encoded><![CDATA[
<p>ggplot2を使わずbeeswarmをつかったドットプロットをわかりやすく説明しました。とても簡単ですが、魅力的な図ができます。</p>



<p>これは私がまだRを触ったことがなかった時、自分が必要に迫られて短時間でドットプロットを書かなくてはいけなかった際、有料ソフトを購入するしかないと諦めていたときに無料で出来る見つけ使った方法です。</p>



<p>そのため、はじめてRを触った人でも真似をすれば出来る方法を紹介します。</p>



<p>ggplot2を使った方法を参照したい方はこちらを参照してください。</p>



https://brain-storm.space/rggplot2_boxplot_dotplot/620/



https://brain-storm.space/ggbeeswarm/820/



<div id="rtoc-mokuji-wrapper" class="rtoc-mokuji-content frame2 preset1 animation-fade rtoc_open default" data-id="698" data-theme="jin-child">
			<div id="rtoc-mokuji-title" class=" rtoc_left">
			<button class="rtoc_open_close rtoc_open"></button>
			<span>Contents</span>
			</div><ol class="rtoc-mokuji decimal_ol level-1"><li class="rtoc-item"><a href="#rtoc-1">データセットの準備とbeeswarmのインストール</a></li><li class="rtoc-item"><a href="#rtoc-2">箱ひげ図を書く</a><ul class="rtoc-mokuji mokuji_ul level-2"><li class="rtoc-item"><a href="#rtoc-3">まずは単純な箱ひげ図をかいていきます</a></li><li class="rtoc-item"><a href="#rtoc-4">ラベルをつけていきましょう</a></li><li class="rtoc-item"><a href="#rtoc-5">x軸の順番を変えたい時はfactorとlevelを追記します</a></li><li class="rtoc-item"><a href="#rtoc-6">colで箱の中を白くします</a></li><li class="rtoc-item"><a href="#rtoc-7">lasで軸の文字の向きを変えることができます</a></li><li class="rtoc-item"><a href="#rtoc-8">ボックスプロットを横向きにします</a></li></ul></li><li class="rtoc-item"><a href="#rtoc-9">beeswarmを箱ひげ図にのせていく</a><ul class="rtoc-mokuji mokuji_ul level-2"><li class="rtoc-item"><a href="#rtoc-10">beeswarmを使っていきます</a></li><li class="rtoc-item"><a href="#rtoc-11">beeswarmでadd = TRUEとすると下の図に重ねることができます</a></li><li class="rtoc-item"><a href="#rtoc-12">色をつけます</a></li><li class="rtoc-item"><a href="#rtoc-13">spacingで点と点の距離を変更できます</a></li></ul></li><li class="rtoc-item"><a href="#rtoc-14">beeswarmのmethodは4つある</a><ul class="rtoc-mokuji mokuji_ul level-2"><li class="rtoc-item"><a href="#rtoc-15">swarm, center, hex, squareの4つあります</a></li><li class="rtoc-item"><a href="#rtoc-16">rnormで乱数をつくってみます</a></li></ul></li><li class="rtoc-item"><a href="#rtoc-17">methodによる違い</a><ul class="rtoc-mokuji mokuji_ul level-2"><li class="rtoc-item"><a href="#rtoc-18">swarm</a></li><li class="rtoc-item"><a href="#rtoc-19">center</a></li><li class="rtoc-item"><a href="#rtoc-20">hex</a></li><li class="rtoc-item"><a href="#rtoc-21">square</a></li><li class="rtoc-item"><a href="#rtoc-22">ラベルを変えてみます</a></li></ul></li><li class="rtoc-item"><a href="#rtoc-23">その他の機能を簡単に紹介します</a><ul class="rtoc-mokuji mokuji_ul level-2"><li class="rtoc-item"><a href="#rtoc-24">corral</a></li><li class="rtoc-item"><a href="#rtoc-25">priority</a></li><li class="rtoc-item"><a href="#rtoc-26">side</a></li></ul></li></ol></div><h2 id="rtoc-1"  class="wp-block-heading">データセットの準備とbeeswarmのインストール</h2>



<p>まずははじめに作業ディレクトリをセットします。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
setwd(&quot;~/Rpractice/&quot;)
</pre></div>


<p>beeswarmのパッケージをインストールしましょう。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
install.packages(&quot;beeswarm&quot;, dependencies = TRUE)
</pre></div>


<p>beeswarmを起動します。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
library(beeswarm)
</pre></div>


<p>アヤメデータを使います。アヤメデータについてはこちらで説明をしています。</p>



https://brain-storm.space/rggplot2_boxplot_dotplot/620/


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
a &lt;- iris
head(a)
&gt; head(a)
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa
4          4.6         3.1          1.5         0.2  setosa
5          5.0         3.6          1.4         0.2  setosa
6          5.4         3.9          1.7         0.4  setosa
&gt; 
</pre></div>


<p>アヤメデータがaに格納されました。これで準備ができました。</p>



<h2 id="rtoc-2"  class="wp-block-heading">箱ひげ図を書く</h2>



<h3 id="rtoc-3"  class="wp-block-heading">まずは単純な箱ひげ図をかいていきます</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(a$Sepal.Length ~ a$Species)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/Rplot02-1024x1024.jpg" alt="" class="wp-image-701" width="512" height="512"/></figure>



<h3 id="rtoc-4"  class="wp-block-heading">ラベルをつけていきましょう</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(a$Sepal.Length ~ a$Species, 
        xlab = &quot;Species&quot;, ylab = &quot;Sepal Length&quot;)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/boxplot_2-1024x1024.jpg" alt="" class="wp-image-702" width="512" height="512"/></figure>



<p>箱ひげ図のかき方はこちらでもいいです。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(data = a, Sepal.Length ~ Species)
</pre></div>


<ul>
<li></li>
</ul>



<h3 id="rtoc-5"  class="wp-block-heading">x軸の順番を変えたい時はfactorとlevelを追記します</h3>



<p>x軸の順番を変える時、factor()の中にlevel=c()で下のように順番を指定します。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(a$Sepal.Length ~ factor(a$Species, 
        level = c('versicolor', 'setosa', 'virginica')), 
        xlab = &quot;Species&quot;, ylab = &quot;Sepal Length&quot;)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/boxplot_4.5-1-1024x1024.jpg" alt="" class="wp-image-1170" width="512" height="512"/></figure>



<h3 id="rtoc-6"  class="wp-block-heading">colで箱の中を白くします</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(data = a, Sepal.Length ~ Species, 
        col = &quot;white&quot;)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/boxplot_3-1024x1024.jpg" alt="" class="wp-image-703" width="512" height="512"/></figure>



<h3 id="rtoc-7"  class="wp-block-heading">lasで軸の文字の向きを変えることができます</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(data = a, Sepal.Length ~ Species, 
        col = &quot;white&quot;, las = 1)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/boxplot_4-1024x1024.jpg" alt="" class="wp-image-705" width="512" height="512"/></figure>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(data = a, Sepal.Length ~ Species, 
        col = &quot;white&quot;, las = 2)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/boxplot_5-1024x1024.jpg" alt="" class="wp-image-706" width="512" height="512"/></figure>



<p>下の文字が重なってしまいましたね。</p>



<h3 id="rtoc-8"  class="wp-block-heading">ボックスプロットを横向きにします</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(data = a, Sepal.Length ~ Species, 
        col = &quot;white&quot;, 
        horizontal = TRUE, las = 2)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/boxplot_hor_6-1024x1024.jpg" alt="" class="wp-image-707" width="512" height="512"/></figure>



<p>横の文字が重なったのと、２番目の文字列が長すぎてきれてしまいました。初心者向けの記事なので、シンプルにアノテーションをなしにして、また少し外側のスペースを増やしましょう。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
par(mar = c(5,5,4,2) + 0.1) 　# default is c(5,4,4,2) + 0.1
boxplot(data = a, Sepal.Length ~ Species, 
        col = &quot;white&quot;, 
        horizontal = TRUE, ann = FALSE, las = 2)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/boxplot_hor_7-1024x1024.jpg" alt="" class="wp-image-708" width="512" height="512"/></figure>



<h2 id="rtoc-9"  class="wp-block-heading">beeswarmを箱ひげ図にのせていく</h2>



<h3 id="rtoc-10"  class="wp-block-heading">beeswarmを使っていきます</h3>



<p>ようやくbeeswarmにたどり着きました。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
beeswarm(data = a, Sepal.Length ~ Species)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/beeswarm1-1-1024x1024.jpg" alt="" class="wp-image-726" width="512" height="512"/></figure>



<h3 id="rtoc-11"  class="wp-block-heading">beeswarmでadd = TRUEとすると下の図に重ねることができます</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(data = a, Sepal.Length ~ Species, col = &quot;white&quot;, las = 1)
beeswarm(data = a, Sepal.Length ~ Species, add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm1-1-1024x1024.jpg" alt="" class="wp-image-727" width="512" height="512"/></figure>



<h3 id="rtoc-12"  class="wp-block-heading">色をつけます</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(data = a, Sepal.Length ~ Species, col = &quot;white&quot;, las = 1)
beeswarm(data = a, Sepal.Length ~ Species,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm2-1-1024x1024.jpg" alt="" class="wp-image-728" width="512" height="512"/></figure>



<p>ドットのスタイルを変えるにはpchを指定します。</p>



<div class="wp-block-jin-gb-block-border jin-sen"><div class="jin-sen-dashed" style="border-width:3px;border-color:#f48789"></div></div>



<div class="wp-block-jin-gb-block-box concept-box6">
<p>pchには25種類用意されています</p>
</div>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/pch_figure-5.png" alt="" class="wp-image-722" width="462" height="259"/></figure>



<div class="wp-block-jin-gb-block-border jin-sen"><div class="jin-sen-dashed" style="border-width:3px;border-color:#f48789"></div></div>



<p>pchを19に指定してみます。好みで選んでください。ちなみに16と19の丸の違いですが、16は普通の丸、19は少し斜め方向に膨らんだような丸になっています。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(data = a, Sepal.Length ~ Species, col = &quot;white&quot;, las = 1)
beeswarm(data = a, Sepal.Length ~ Species,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         pch = 19,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm3-1-1024x1024.jpg" alt="" class="wp-image-729" width="512" height="512"/></figure>



<p>cexでドットの大きさを変えます。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(data = a, Sepal.Length ~ Species, col = &quot;white&quot;, las = 1)
beeswarm(data = a, Sepal.Length ~ Species,
         method = &quot;swarm&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         pch = 19,
         cex = 1.3,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm4-1-1024x1024.jpg" alt="" class="wp-image-730" width="512" height="512"/></figure>



<h3 id="rtoc-13"  class="wp-block-heading">spacingで点と点の距離を変更できます</h3>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm5-1024x1024.jpg" alt="" class="wp-image-731" width="512" height="512"/></figure>



<h2 id="rtoc-14"  class="wp-block-heading">beeswarmのmethodは4つある</h2>



<h3 id="rtoc-15"  class="wp-block-heading">swarm, center, hex, squareの4つあります</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(data = a, Sepal.Length ~ Species, col = &quot;white&quot;, las = 1)
beeswarm(data = a, Sepal.Length ~ Species,
         method = &quot;swarm&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         pch = 19,
         cex = 1.3,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm6_swarm-1024x1024.jpg" alt="" class="wp-image-733" width="512" height="512"/></figure>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(data = a, Sepal.Length ~ Species, col = &quot;white&quot;, las = 1)
beeswarm(data = a, Sepal.Length ~ Species,
         method = &quot;center&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         pch = 19,
         cex = 1.3,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm6-1024x1024.jpg" alt="" class="wp-image-732" width="512" height="512"/></figure>



<p>アヤメデータは小数点1桁までなので、methodによる違いがあまりはっきりしません。</p>



<h3 id="rtoc-16"  class="wp-block-heading">rnormで乱数をつくってみます</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
x &lt;- rnorm(100, 10, 10)
y &lt;- rnorm(100, 25, 10)
z &lt;- rnorm(100, 20, 15)
</pre></div>


<p>それぞれのmethodによるグラフの違いをみていきましょう</p>



<h2 id="rtoc-17"  class="wp-block-heading">methodによる違い</h2>



<p>もう一度methodの違いを見ていきます</p>



<h3 id="rtoc-18"  class="wp-block-heading">swarm</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(list(x, y, z), col = &quot;white&quot;, las = 1)
beeswarm(list(x, y, z),
         method = &quot;swarm&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         spacing = 0.6,
         cex = 1.3,
         pch = 19,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm7_swarm-1024x1024.jpg" alt="" class="wp-image-734" width="512" height="512"/></figure>



<h3 id="rtoc-19"  class="wp-block-heading">center</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(list(x, y, z), col = &quot;white&quot;, las = 1)
beeswarm(list(x, y, z),
         method = &quot;center&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         spacing = 0.9,
         cex = 1.3,
         pch = 19,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm7_center-1024x1024.jpg" alt="" class="wp-image-735" width="512" height="512"/></figure>



<h3 id="rtoc-20"  class="wp-block-heading">hex</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(list(x, y, z), col = &quot;white&quot;, las = 1)
beeswarm(list(x, y, z),
         method = &quot;hex&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         spacing = .9,
         cex = 1.3,
         pch = 19,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm7_hex-1024x1024.jpg" alt="" class="wp-image-736" width="512" height="512"/></figure>



<h3 id="rtoc-21"  class="wp-block-heading">square</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(list(x, y, z), col = &quot;white&quot;, las = 1)
beeswarm(list(x, y, z),
         method = &quot;square&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         cex = 1.3,
         spacing = .9,
         pch = 19,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm7_square-1024x1024.jpg" alt="" class="wp-image-737" width="512" height="512"/></figure>



<h3 id="rtoc-22"  class="wp-block-heading">ラベルを変えてみます</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(list(x, y, z),
        names = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;),
        xlab = &quot;Names&quot;,
        ylab =&quot;Values&quot;,
        col = &quot;white&quot;,
        las = 1,
        cex.lab = 1.5,
        cex.axis = 1.5)
beeswarm(list(x, y, z),
         method = &quot;swarm&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         pch = 19,
         spacing = .6,
         priority = &quot;density&quot;,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm8-1024x1024.jpg" alt="" class="wp-image-738" width="512" height="512"/></figure>



<h2 id="rtoc-23"  class="wp-block-heading">その他の機能を簡単に紹介します</h2>



<h3 id="rtoc-24"  class="wp-block-heading">corral</h3>



<p>corralは点が大きく外側に外れたものを調整する方法です。</p>



<p>&#8220;none&#8221;, &#8220;gutter&#8221;, &#8220;wrap&#8221;, &#8220;random&#8221;, &#8220;omit&#8221;の5つの方法があります。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(list(x, y, z),
        names = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;),
        xlab = &quot;Names&quot;,
        ylab =&quot;Values&quot;,
        col = &quot;white&quot;,
        las = 1,
        cex.lab = 1.5,
        cex.axis = 1.5)
beeswarm(list(x, y, z),
         method = &quot;swarm&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         corral = &quot;wrap&quot;,
         cex = 1.3,
         spacing = .9,
         pch = 19,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm9_wrap-1024x1024.jpg" alt="" class="wp-image-740" width="512" height="512"/></figure>



<h3 id="rtoc-25"  class="wp-block-heading">priority</h3>



<p>点の配置ですが、実際に見てみたほうがわかりやすいです。</p>



<h4 class="wp-block-heading">descending</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(list(x, y, z),
        names = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;),
        xlab = &quot;Names&quot;,
        ylab =&quot;Values&quot;,
        col = &quot;white&quot;,
        las = 1,
        cex.lab = 1.5,
        cex.axis = 1.5)
beeswarm(list(x, y, z),
         method = &quot;swarm&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         pch = 19,
         cex = 1.3,
         spacing = .9,
         priority = &quot;descending&quot;,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm10_descending-1024x1024.jpg" alt="" class="wp-image-741" width="512" height="512"/></figure>



<h4 class="wp-block-heading">random</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(list(x, y, z),
        names = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;),
        xlab = &quot;Names&quot;,
        ylab =&quot;Values&quot;,
        col = &quot;white&quot;,
        las = 1,
        cex.lab = 1.5,
        cex.axis = 1.5)
beeswarm(list(x, y, z),
         method = &quot;swarm&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         pch = 19,
         spacing = .9,
         priority = &quot;random&quot;,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm10_random-1024x1024.jpg" alt="" class="wp-image-742" width="512" height="512"/></figure>



<h4 class="wp-block-heading">density</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(list(x, y, z),
        names = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;),
        xlab = &quot;Names&quot;,
        ylab =&quot;Values&quot;,
        col = &quot;white&quot;,
        las = 1,
        cex.lab = 1.5,
        cex.axis = 1.5)
beeswarm(list(x, y, z),
         method = &quot;swarm&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         pch = 19,
         spacing = .9,
         priority = &quot;density&quot;,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm10_density-1024x1024.jpg" alt="" class="wp-image-743" width="512" height="512"/></figure>



<h3 id="rtoc-26"  class="wp-block-heading">side</h3>



<p>点を右側か左側に集めます。</p>



<h4 class="wp-block-heading">side = 1</h4>



<p>右側に集めます。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(list(x, y, z),
        names = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;),
        xlab = &quot;Names&quot;,
        ylab =&quot;Values&quot;,
        col = &quot;white&quot;,
        las = 1,
        cex.lab = 1.5,
        cex.axis = 1.5)
beeswarm(list(x, y, z),
         method = &quot;swarm&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         pch = 19,
         spacing = .9,
         side = 1,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm11_side1-1024x1024.jpg" alt="" class="wp-image-744" width="512" height="512"/></figure>



<h4 class="wp-block-heading">side = -1</h4>



<p>左側に集めます。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: r; title: Code example; notranslate">
boxplot(list(x, y, z),
        names = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;),
        xlab = &quot;Names&quot;,
        ylab =&quot;Values&quot;,
        col = &quot;white&quot;,
        las = 1,
        cex.lab = 1.5,
        cex.axis = 1.5)
beeswarm(list(x, y, z),
         method = &quot;swarm&quot;,
         col = c(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;),
         pch = 19,
         spacing = .9,
         side = -1,
         add = TRUE)
</pre></div>


<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://brain-storm.space/wp-content/uploads/2021/05/box_beeswarm11_side-1-1024x1024.jpg" alt="" class="wp-image-745" width="512" height="512"/></figure>



<p>無料のオープンソースでここまでできるのはすごいですよね。</p>



<p>ggplot2とggbeeswarmを使った方法はこちらで紹介をしています。</p>



<p>どちらがいいかは好みですので、どちらでも使いやすいほうを使うのがいいと思います。</p>



https://brain-storm.space/ggbeeswarm/820/



<p>お役に立ちましたら幸いです。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://brain-storm.space/beeswarm_r/698/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
