{"id":32,"date":"2007-12-12T11:00:57","date_gmt":"2007-12-12T10:00:57","guid":{"rendered":"http:\/\/www.walkingrandomly.com\/?p=32"},"modified":"2010-01-31T20:01:27","modified_gmt":"2010-01-31T19:01:27","slug":"changing-the-x-axis-origin-for-listplot-in-mathematica","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=32","title":{"rendered":"Changing the x-axis origin for ListPlot in Mathematica"},"content":{"rendered":"<p>Recently, someone over at comp.soft-sys.math.mathematica had a simple problem &#8211; he had a 1d array of y-values which he wanted to plot.  Easy enough &#8211; if his array is in a variable called <strong>dataset<\/strong> all he would need to do is<\/p>\n<pre>\r\nListplot[dataset]\r\n<\/pre>\n<p>which would create a plot of x-y values with the x values being 1,2,3&#8230;.. and so on. The problem the poster had was that he wanted the x-axis to start at 100 rather than the default which is 1.<\/p>\n<p>Several people, including me, tried to be helpful and posted solutions that were along the lines of &#8216;create an explicit set of x-values, starting at 100, do some trickery to turn the two arrays into a set of x,y pairs and plot the result&#8217;.  For example you could do this with<\/p>\n<pre>\r\n(*Assume that the array is in a variable called dataset*)\r\nx = Range[100, 100 + Length[dataset] - 1];\r\nListPlot[Transpose@{x, dataset}]\r\n<\/pre>\n<p>This works fine but we should have read the new version 6 documentation because (as pointed out by someone else on the forum) there is now a much easier way of doing this using the DataRange option.<\/p>\n<pre>\r\nListPlot[dataset, DataRange -&gt; {100, 100 + Length[dataset]}]\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Recently, someone over at comp.soft-sys.math.mathematica had a simple problem &#8211; he had a 1d array of y-values which he wanted to plot. Easy enough &#8211; if his array is in a variable called dataset all he would need to do is Listplot[dataset] which would create a plot of x-y values with the x values being [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,8],"tags":[],"class_list":["post-32","post","type-post","status-publish","format-standard","hentry","category-math-software","category-mathematica"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-w","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/32","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=32"}],"version-history":[{"count":1,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions"}],"predecessor-version":[{"id":2259,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions\/2259"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}