{"action":"created","issue":{"url":"https://api.github.com/repos/hadley/ggplot2/issues/969","labels_url":"https://api.github.com/repos/hadley/ggplot2/issues/969/labels{/name}","comments_url":"https://api.github.com/repos/hadley/ggplot2/issues/969/comments","events_url":"https://api.github.com/repos/hadley/ggplot2/issues/969/events","html_url":"https://github.com/hadley/ggplot2/pull/969","id":34726626,"number":969,"title":"Coord expand","user":{"login":"lionel-","id":4465050,"avatar_url":"https://avatars.githubusercontent.com/u/4465050?v=3","gravatar_id":"","url":"https://api.github.com/users/lionel-","html_url":"https://github.com/lionel-","followers_url":"https://api.github.com/users/lionel-/followers","following_url":"https://api.github.com/users/lionel-/following{/other_user}","gists_url":"https://api.github.com/users/lionel-/gists{/gist_id}","starred_url":"https://api.github.com/users/lionel-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lionel-/subscriptions","organizations_url":"https://api.github.com/users/lionel-/orgs","repos_url":"https://api.github.com/users/lionel-/repos","events_url":"https://api.github.com/users/lionel-/events{/privacy}","received_events_url":"https://api.github.com/users/lionel-/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2014-06-01T11:23:57Z","updated_at":"2015-07-27T18:55:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/hadley/ggplot2/pulls/969","html_url":"https://github.com/hadley/ggplot2/pull/969","diff_url":"https://github.com/hadley/ggplot2/pull/969.diff","patch_url":"https://github.com/hadley/ggplot2/pull/969.patch"},"body":"The difference between setting the limits through a coordinate system or via a scale is central to ggplot but the two procedures are not consistent with each other. Compared to scales, the coord functions lack an expand argument. More importantly, they do not apply the default expansion and the same plot will look different in function of which method was used to set limits.\r\n\r\nThis pull request implements `xexpand` and `yexpand` arguments for coord functions, with the same default expansion as for the scales.\r\n\r\nSince setting the limits through coord is symmetric to setting the limits with scales, it should happen in the same place in the code. Furthermore, this allows to know if the scale is continuous or discrete thanks to the scale object being passed along. To make this possible, I changed the coord object to reflect the scale object structure. Coord objects now contains two lists named `x` and `y`, each containing `expand` and limits. In order to make the difference between passing the whole coord object and passing the x or y component, I added a dot to `coord`. When a function receives a `.coord`, we know it is the x or y component of a coord object.\r\n\r\nOne difficulty that I encountered while checking that everything was ok, is that coord_polar does not have the x and y components. And it needs special treatment for the default expansion, which depends on theta being equal to \"x\" or \"y\".  My solution was to add x and y objects, containing theta, with class set to \"polar\" so that `coord_expand_defaults` dispatches correctly the .coord object to `coord_expand_defaults.polar`."},"comment":{"url":"https://api.github.com/repos/hadley/ggplot2/issues/comments/125304710","html_url":"https://github.com/hadley/ggplot2/pull/969#issuecomment-125304710","issue_url":"https://api.github.com/repos/hadley/ggplot2/issues/969","id":125304710,"user":{"login":"hadley","id":4196,"avatar_url":"https://avatars.githubusercontent.com/u/4196?v=3","gravatar_id":"","url":"https://api.github.com/users/hadley","html_url":"https://github.com/hadley","followers_url":"https://api.github.com/users/hadley/followers","following_url":"https://api.github.com/users/hadley/following{/other_user}","gists_url":"https://api.github.com/users/hadley/gists{/gist_id}","starred_url":"https://api.github.com/users/hadley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadley/subscriptions","organizations_url":"https://api.github.com/users/hadley/orgs","repos_url":"https://api.github.com/users/hadley/repos","events_url":"https://api.github.com/users/hadley/events{/privacy}","received_events_url":"https://api.github.com/users/hadley/received_events","type":"User","site_admin":false},"created_at":"2015-07-27T18:55:28Z","updated_at":"2015-07-27T18:55:28Z","body":"Do you want to have a go? Otherwise, because it's bug, I'll do it."}}