{"id":2010,"date":"2017-07-14T18:23:50","date_gmt":"2017-07-14T17:23:50","guid":{"rendered":"http:\/\/pcool.dyndns.org:8080\/statsbook\/?page_id=2010"},"modified":"2025-07-01T10:42:49","modified_gmt":"2025-07-01T09:42:49","slug":"sunflower-plot","status":"publish","type":"page","link":"https:\/\/pcool.dyndns.org\/index.php\/sunflower-plot\/","title":{"rendered":"Sunflower Plot"},"content":{"rendered":"\n<p>A sunflower plot is&nbsp;a special type of scatterplot. It is particularly useful for high density data. When plotted, high density data points will be plotted on top of each other, making the plot difficult to interpret as it is uncertain&nbsp;how many data points are plotted.<\/p>\n\n\n\n<p>For example, consider the following data frame\u00a0<a href=\"https:\/\/pcool.dyndns.org:\/wp-content\/data_files\/sun.rda\" target=\"_blank\" rel=\"noreferrer noopener\">sun.rda<\/a>\u00a0with 21\u00a0observations:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><em><mark style=\"background-color:rgba(0, 0, 0, 0);color:#f50707\" class=\"has-inline-color\">sun\n<\/mark><mark style=\"background-color:rgba(0, 0, 0, 0);color:#1507f5\" class=\"has-inline-color\">     X    Y\n1  0.5 0.75\n2  0.9 0.92\n3  0.9 0.92\n4  1.1 1.50\n5  1.1 1.50\n6  1.1 1.50\n7  1.7 1.85\n8  1.7 1.85\n9  1.7 1.85\n10 1.7 1.85\n11 1.9 2.40\n12 1.9 2.40\n13 1.9 2.40\n14 1.9 2.40\n15 1.9 2.40\n16 2.2 2.70\n17 2.2 2.70\n18 2.2 2.70\n19 2.2 2.70\n20 2.2 2.70\n21 2.2 2.70<\/mark><\/em><\/code><\/pre>\n\n\n\n<p>To create a simple scatterplot using base R:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><em><span style=\"color: #ff0000;\">plot(sun)<\/span><\/em><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"971\" src=\"https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/sun1-1024x971.png\" alt=\"\" class=\"wp-image-3673\" srcset=\"https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/sun1-1024x971.png 1024w, https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/sun1-300x284.png 300w, https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/sun1-768x728.png 768w, https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/sun1.png 1422w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This plot suggests there are only&nbsp;6 data points, whilst in fact there are 21. The data points are plotted on top of each other as they have the same value (there is a high density). A sunflower plot is a better option as it shows there are&nbsp;21 data points:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code><em><span style=\"color: #ff0000;\">sunflowerplot(sun)<\/span><\/em><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"982\" src=\"https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/sun2-1024x982.png\" alt=\"\" class=\"wp-image-3678\" srcset=\"https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/sun2-1024x982.png 1024w, https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/sun2-300x288.png 300w, https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/sun2-768x737.png 768w, https:\/\/pcool.dyndns.org\/wp-content\/uploads\/2025\/06\/sun2.png 1420w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The density of the data is much easier to appreciate. In the sunflower plot,&nbsp;each petal represents a single observation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A sunflower plot is&nbsp;a special type of scatterplot. It is particularly useful for high density data. When plotted, high density data points will be plotted on top of each other, making the plot difficult to interpret as it is uncertain&nbsp;how many data points are plotted. For example, consider the following data frame\u00a0sun.rda\u00a0with 21\u00a0observations: To create [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"footnotes":""},"class_list":["post-2010","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/pages\/2010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/comments?post=2010"}],"version-history":[{"count":1,"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/pages\/2010\/revisions"}],"predecessor-version":[{"id":4688,"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/pages\/2010\/revisions\/4688"}],"wp:attachment":[{"href":"https:\/\/pcool.dyndns.org\/index.php\/wp-json\/wp\/v2\/media?parent=2010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}