<style type="text/css">
    /* Add Social Bookmars Plugin By Aditya Subawa @ www.adityawebs.com */
    ul.aditya-social { list-style:none; margin:15px auto;display:inline-block; }
    ul.aditya-social li { display:inline; float:left; background-repeat:no-repeat; }
    ul.aditya-social li a { display:block; width:48px; height:48px; padding-right:10px; position:relative; text-decoration:none; }
    ul.aditya-social li a strong { font-weight:normal; position:absolute; left:20px; top:-1px; color:#fff; padding:3px; z-index:9999; text-shadow:1px 1px 0 rgba(0, 0, 0, 0.75); background-color:rgba(0, 0, 0, 0.7); -moz-border-radius:3px; -moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.5); -webkit-border-radius:3px; -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.5); border-radius:3px; box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);}
    ul.aditya-social li.aditya-facebook { background-image:url("/wp-content/plugins/wp-add-socialbookmarks/images/facebook.png"); }
    ul.aditya-social li.aditya-twitter { background-image:url("/wp-content/plugins/wp-add-socialbookmarks/images/twitter.png"); }
    ul.aditya-social li.aditya-stumbleupon { background-image:url("/wp-content/plugins/wp-add-socialbookmarks/images/stumbleupon.png"); }
    ul.aditya-social li.aditya-digg { background-image:url("/wp-content/plugins/wp-add-socialbookmarks/images/digg.png"); }
    ul.aditya-social li.aditya-delicious { background-image:url("/wp-content/plugins/wp-add-socialbookmarks/images/delicious.png"); }
    ul.aditya-social li.aditya-yahoo { background-image:url("/wp-content/plugins/wp-add-socialbookmarks/images/yahoo.png"); }
    ul.aditya-social li.aditya-reddit { background-image:url("/wp-content/plugins/wp-add-socialbookmarks/images/reddit.png"); }
    ul.aditya-social li.aditya-technorati { background-image:url("/wp-content/plugins/wp-add-socialbookmarks/images/technorati.png"); }
    #aditya-cssanime:hover li { opacity:0.2; }
    #aditya-cssanime li { -webkit-transition-property: opacity; -webkit-transition-duration: 500ms;-moz-transition-property: opacity; -moz-transition-duration: 500ms; }
    #aditya-cssanime li a strong { opacity:0; -webkit-transition-property: opacity, top; -webkit-transition-duration: 300ms; -moz-transition-property: opacity, top; -moz-transition-duration: 300ms; }
    #aditya-cssanime li:hover { opacity:1; }
    #aditya-cssanime li:hover a strong { opacity:1; top:-10px; }
    /* Add Social Bookmarks Plugins By Aditya Subawa @ www.adityawebs.com */
    </style>

{"id":1040,"date":"2012-11-14T22:50:43","date_gmt":"2012-11-14T22:50:43","guid":{"rendered":"http:\/\/johncanning.net\/wordpress\/?p=1040"},"modified":"2016-03-11T16:41:50","modified_gmt":"2016-03-11T16:41:50","slug":"1040","status":"publish","type":"post","link":"https:\/\/johncanning.net\/wp\/?p=1040","title":{"rendered":"Using pgfplot LaTeX package for basic dotplots."},"content":{"rendered":"<p><span style=\"color: #ff0000;\">Amended 11 March 2016<\/span><\/p>\n<p>I wanted to produce a basic dotplot using the LaTeX <a title=\"PGFplots\" href=\"http:\/\/pgfplots.sourceforge.net\/\">pgfplot package<\/a>. I looked for guidance in the extensive <a title=\"pgfplot manual\" href=\"http:\/\/www.bakoma-tex.com\/doc\/latex\/pgfplots\/pgfplots.pdf\">manual <\/a>but didn't find what I wanted (that is not to say it's not there). I managed to find a workaround, which I have shared here. The results are not perfect, but will do for now.<\/p>\n<p>This is the table containing my data:<\/p>\n<table border=\"0\">\n<tbody>\n<tr>\n<td><strong>Subject<\/strong><\/td>\n<td><strong>Marks out of ten<\/strong><\/td>\n<td><strong>Mean Average<\/strong><\/td>\n<td><strong>Median average<\/strong><\/td>\n<\/tr>\n<tr>\n<td>French<\/td>\n<td>2, 4, 5, 7, 7<\/td>\n<td>5<\/td>\n<td>5<\/td>\n<\/tr>\n<tr>\n<td>Religious Studies<\/td>\n<td>0, 5, 10, 7, 3<\/td>\n<td>5<\/td>\n<td>5<\/td>\n<\/tr>\n<tr>\n<td>History<\/td>\n<td>5, 5, 4, 6, 5<\/td>\n<td>5<\/td>\n<td>5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>I used the scatterplot as the basis for the dotplot and worked out this code.<\/p>\n<p>I did three of these. Here are the results. Not too bad.<\/p>\n<p><code><br \/>\n\\documentclass{article}<br \/>\n\\usepackage{pgfplots}<br \/>\n\\pgfplotsset{compat=1.9}<br \/>\n\\begin{document}<br \/>\n\\begin{figure}<br \/>\n\\centering<br \/>\n\\caption{Dotplot: French}<br \/>\n\\begin{tikzpicture}<br \/>\n\\begin{axis}[<br \/>\nxlabel={Marks out of ten},<br \/>\nylabel={},%no label for the y axis<br \/>\nyticklabels={}, %no numbers displayed on the y<br \/>\nymin=0,<br \/>\nymax=10,<br \/>\nxline,<br \/>\nxmin=0, %sets the minimum of the x axis<br \/>\nxmax=10, %sets the max of the x axis.<br \/>\n%As the test was out of ten I have set max to 10.<br \/>\n]<br \/>\n\\addplot[scatter,only marks,<br \/>\nscatter src=explicit symbolic]<br \/>\ncoordinates<br \/>\n{<br \/>\n(2,0) %the first number is the marks out of ten (the x axis).<br \/>\n% Use 0 for the y axis until the second occurrence.<br \/>\n(4,0)<br \/>\n(5,0)<br \/>\n(7,0)<br \/>\n(7,1) %the second number here is 1 because we have already used 7,0.<br \/>\n%This is because 2 people got 7 out of 10.<br \/>\n};<br \/>\n\\end{axis}<br \/>\n\\end{tikzpicture}<br \/>\n\\end{figure}<br \/>\n\\end{document}<br \/>\n<\/code><\/p>\n<p><a href=\"http:\/\/johncanning.net\/wp\/wp-content\/uploads\/2012\/11\/dotplots.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1045 alignleft\" title=\"dotplots\" src=\"http:\/\/johncanning.net\/wp\/wp-content\/uploads\/2012\/11\/dotplots.png\" alt=\"Dotplot output from pgfplot package\" width=\"450\" height=\"705\" srcset=\"https:\/\/johncanning.net\/wp\/wp-content\/uploads\/2012\/11\/dotplots.png 450w, https:\/\/johncanning.net\/wp\/wp-content\/uploads\/2012\/11\/dotplots-191x300.png 191w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n\n\n<ul class=\"aditya-social\" id=\"aditya-cssanime\">\n<li class=\"aditya-twitter\"><a href=\"http:\/\/twitter.com\/share?url=https%3A%2F%2Fjohncanning.net%2Fwp%2F%3Fp%3D1040&amp;url=https%3A%2F%2Fjohncanning.net%2Fwp%2F%3Fp%3D1040\" target=\"_blank\" rel=\"nofollow\" title=\"Twitter\"><img decoding=\"async\" src=\"http:\/\/johncanning.net\/wp\/wp-content\/plugins\/wp-add-social-bookmarks\/images\/twitter.png\" alt=\"Twitter\" title=\"Twitter\" \/><\/a><\/li>\n<li class=\"aditya-delicious\"><a href=\"http:\/\/del.icio.us\/post?url=https%3A%2F%2Fjohncanning.net%2Fwp%2F%3Fp%3D1040&amp;title=Using+pgfplot+LaTeX+package+for+basic+dotplots.\" target=\"_blank\" rel=\"nofollow\" title=\"del.icio.us\"><img decoding=\"async\" src=\"http:\/\/johncanning.net\/wp\/wp-content\/plugins\/wp-add-social-bookmarks\/images\/delicious.png\" alt=\"del.icio.us\" title=\"del.icio.us\" \/><\/a><\/li>\n<li class=\"aditya-digg\"><a href=\"http:\/\/digg.com\/submit?phase=2&amp;url=https%3A%2F%2Fjohncanning.net%2Fwp%2F%3Fp%3D1040&amp;title=Using+pgfplot+LaTeX+package+for+basic+dotplots.\" target=\"_blank\" rel=\"nofollow\" title=\"Digg\"><img decoding=\"async\" src=\"http:\/\/johncanning.net\/wp\/wp-content\/plugins\/wp-add-social-bookmarks\/images\/digg.png\" alt=\"Digg\" title=\"Digg\" \/><\/a><\/li>\n<li class=\"aditya-facebook\"><a href=\"http:\/\/facebook.com\/sharer.php?u=https%3A%2F%2Fjohncanning.net%2Fwp%2F%3Fp%3D1040&amp;t=Using+pgfplot+LaTeX+package+for+basic+dotplots.\" target=\"_blank\" rel=\"nofollow\" title=\"Facebook\"><img decoding=\"async\" src=\"http:\/\/johncanning.net\/wp\/wp-content\/plugins\/wp-add-social-bookmarks\/images\/facebook.png\" alt=\"Facebook\" title=\"Facebook\" \/><\/a><\/li>\n<li class=\"aditya-technorati\"><a href=\"http:\/\/technorati.com\/faves?add=https%3A%2F%2Fjohncanning.net%2Fwp%2F%3Fp%3D1040\" target=\"_blank\" rel=\"nofollow\" title=\"Technorati\"><img decoding=\"async\" src=\"http:\/\/johncanning.net\/wp\/wp-content\/plugins\/wp-add-social-bookmarks\/images\/technorati.png\" alt=\"Technorati\" title=\"Technorati\" \/><\/a><\/li>\n<li class=\"aditya-reddit\"><a href=\"http:\/\/reddit.com\/submit?url=Using+pgfplot+LaTeX+package+for+basic+dotplots.&amp;u=https%3A%2F%2Fjohncanning.net%2Fwp%2F%3Fp%3D1040\" target=\"_blank\" rel=\"nofollow\" title=\"Reddit\"><img decoding=\"async\" src=\"http:\/\/johncanning.net\/wp\/wp-content\/plugins\/wp-add-social-bookmarks\/images\/reddit.png\" alt=\"Reddit\" title=\"Reddit\" \/><\/a><\/li>\n<li class=\"aditya-yahoo\"><a href=\"http:\/\/buzz.yahoo.com\/submit?submitUrl=Using+pgfplot+LaTeX+package+for+basic+dotplots.&amp;u=https%3A%2F%2Fjohncanning.net%2Fwp%2F%3Fp%3D1040\" target=\"_blank\" rel=\"nofollow\" title=\"Yahoo Buzz\"><img decoding=\"async\" src=\"http:\/\/johncanning.net\/wp\/wp-content\/plugins\/wp-add-social-bookmarks\/images\/yahoo.png\" alt=\"Yahoo Buzz\" title=\"Yahoo Buzz\" \/><\/a><\/li>\n<li class=\"aditya-stumbleupon\"><a href=\"http:\/\/stumbleupon.com\/submit?url=https%3A%2F%2Fjohncanning.net%2Fwp%2F%3Fp%3D1040&amp;title=Using+pgfplot+LaTeX+package+for+basic+dotplots.&amp;newcomment=Using+pgfplot+LaTeX+package+for+basic+dotplots.\" target=\"_blank\" rel=\"nofollow\" title=\"StumbleUpon\"><img decoding=\"async\" src=\"http:\/\/johncanning.net\/wp\/wp-content\/plugins\/wp-add-social-bookmarks\/images\/stumbleupon.png\" alt=\"StumbleUpon\" title=\"StumbleUpon\" \/><\/a><\/li>\n<\/ul>\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>Amended 11 March 2016 I wanted to produce a basic dotplot using the LaTeX pgfplot package. I looked for guidance in the extensive manual but didn't find what I wanted (that is not to say it's not there). I managed to find a workaround, which I have shared here. The results are not perfect, but &hellip; <a href=\"https:\/\/johncanning.net\/wp\/?p=1040\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Using pgfplot LaTeX package for basic dotplots.<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,66],"tags":[],"class_list":["post-1040","post","type-post","status-publish","format-standard","hentry","category-latex","category-statistics"],"_links":{"self":[{"href":"https:\/\/johncanning.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/johncanning.net\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/johncanning.net\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/johncanning.net\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/johncanning.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1040"}],"version-history":[{"count":2,"href":"https:\/\/johncanning.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1040\/revisions"}],"predecessor-version":[{"id":2241,"href":"https:\/\/johncanning.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1040\/revisions\/2241"}],"wp:attachment":[{"href":"https:\/\/johncanning.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/johncanning.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/johncanning.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}