{"action":"created","issue":{"url":"https://api.github.com/repos/tidyverse/ggplot2/issues/2817","repository_url":"https://api.github.com/repos/tidyverse/ggplot2","labels_url":"https://api.github.com/repos/tidyverse/ggplot2/issues/2817/labels{/name}","comments_url":"https://api.github.com/repos/tidyverse/ggplot2/issues/2817/comments","events_url":"https://api.github.com/repos/tidyverse/ggplot2/issues/2817/events","html_url":"https://github.com/tidyverse/ggplot2/pull/2817","id":349293512,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3NDQ2MDcx","number":2817,"title":"(WIP) Implement new coord_mirror() and theme_rtl() for RtL plotting","user":{"login":"dpseidel","id":16724456,"node_id":"MDQ6VXNlcjE2NzI0NDU2","avatar_url":"https://avatars1.githubusercontent.com/u/16724456?v=4","gravatar_id":"","url":"https://api.github.com/users/dpseidel","html_url":"https://github.com/dpseidel","followers_url":"https://api.github.com/users/dpseidel/followers","following_url":"https://api.github.com/users/dpseidel/following{/other_user}","gists_url":"https://api.github.com/users/dpseidel/gists{/gist_id}","starred_url":"https://api.github.com/users/dpseidel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpseidel/subscriptions","organizations_url":"https://api.github.com/users/dpseidel/orgs","repos_url":"https://api.github.com/users/dpseidel/repos","events_url":"https://api.github.com/users/dpseidel/events{/privacy}","received_events_url":"https://api.github.com/users/dpseidel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-08-09T21:15:04Z","updated_at":"2018-08-09T22:13:34Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/tidyverse/ggplot2/pulls/2817","html_url":"https://github.com/tidyverse/ggplot2/pull/2817","diff_url":"https://github.com/tidyverse/ggplot2/pull/2817.diff","patch_url":"https://github.com/tidyverse/ggplot2/pull/2817.patch"},"body":"This PR is a WIP. Inspired by [this article](http://rnotr.com/ggplot/plotly/arabic-plots/), I have begun playing around with how to implement RtL plotting in ggplot2. Though there seems to be some debate about what is a [correct](https://www.quora.com/In-right-to-left-languages-are-chart-axes-drawn-differently) [implementation](https://ux.stackexchange.com/questions/42895/right-to-left-graph-labels-for-right-to-left-languages) of RtL axes and it seems many RtL languages plot LtR anyhow, I think the functionality is really neat and ggplot2 should consider adding features that make it possible for the audiences that would use it. In that vein.... \r\n\r\nCurrently this implementation was really quite simple.  I simply adapted `coord_flip()` to create a new `coord_mirror()` and then added a new `theme_rtl()`. This doesn't yet deal with the text encoding issue mentioned in the original article but as they note much of that is OS specific so possibly/probably outside the scope of ggplot2. \r\n\r\nAs currently implemented, a RtL plot requires 3 specifications: the new theme, the new coord, and (at least for continuous data) `scale_x_reverse()`. I wonder if there is a better way to go about this or a way to bundle these three elements together in some sort of default. Example below:\r\n``` r\r\nlibrary(ggplot2)\r\nlibrary(tibble)\r\ndf <- tibble(x = 1:10, y = 1:10, z = rep(c(\"A\", \"B\"), 5))\r\nggplot(df, aes(x, y, col = z)) + \r\n  geom_point() + \r\n  coord_mirror() + \r\n  theme_rtl() + \r\n  scale_x_reverse() +\r\n  ggtitle(\"Right Aligned Title\")\r\n```\r\n\r\n![](https://i.imgur.com/YcyG5it.png)\r\n\r\n``` r\r\n\r\ndf2 <- tibble(x = letters[1:10], y = 1:10, z = rep(c(\"A\", \"B\"), 5))\r\nggplot(df2, aes(x, y, col = z)) + \r\n  geom_point() + \r\n  coord_mirror() + \r\n  theme_rtl() +\r\n  ggtitle(\"Right Aligned Title\")\r\n```\r\n\r\n![](https://i.imgur.com/YgAPJol.png)\r\n\r\n@isteves has been super helpful in thinking about this, and may have some opinions to add to any discussion or iteration so I'm tagging her here. "},"comment":{"url":"https://api.github.com/repos/tidyverse/ggplot2/issues/comments/411914915","html_url":"https://github.com/tidyverse/ggplot2/pull/2817#issuecomment-411914915","issue_url":"https://api.github.com/repos/tidyverse/ggplot2/issues/2817","id":411914915,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMTkxNDkxNQ==","user":{"login":"dpseidel","id":16724456,"node_id":"MDQ6VXNlcjE2NzI0NDU2","avatar_url":"https://avatars1.githubusercontent.com/u/16724456?v=4","gravatar_id":"","url":"https://api.github.com/users/dpseidel","html_url":"https://github.com/dpseidel","followers_url":"https://api.github.com/users/dpseidel/followers","following_url":"https://api.github.com/users/dpseidel/following{/other_user}","gists_url":"https://api.github.com/users/dpseidel/gists{/gist_id}","starred_url":"https://api.github.com/users/dpseidel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpseidel/subscriptions","organizations_url":"https://api.github.com/users/dpseidel/orgs","repos_url":"https://api.github.com/users/dpseidel/repos","events_url":"https://api.github.com/users/dpseidel/events{/privacy}","received_events_url":"https://api.github.com/users/dpseidel/received_events","type":"User","site_admin":false},"created_at":"2018-08-09T22:13:34Z","updated_at":"2018-08-09T22:13:34Z","author_association":"MEMBER","body":"Great! Thanks for the quick code @clauswilke! It's mplemented now and things actually *mirror* as you would expect without the `scale_x_reverse()` call.  \r\n\r\n``` r\r\nlibrary(ggplot2)\r\nlibrary(tibble)\r\ndf <- tibble(x = 1:10, y = 1:10, z = rep(c(\"A\", \"B\"), 5))\r\nggplot(df, aes(x, y, col = z)) +\r\n  geom_point() +\r\n  coord_mirror() +\r\n  theme_rtl() +\r\n  ggtitle(\"Right Aligned Title\")\r\n```\r\n\r\n![](https://i.imgur.com/wxPWljC.png)\r\n\r\n``` r\r\n\r\ndf2 <- tibble(x = letters[1:10], y = 1:10, z = rep(c(\"A\", \"B\"), 5))\r\nggplot(df2, aes(x, y, col = z)) +\r\n  geom_point() +\r\n  coord_mirror() +\r\n  theme_rtl() +\r\n  ggtitle(\"Right Aligned Title\")\r\n```\r\n\r\n![](https://i.imgur.com/uWhnZ0C.png)\r\n\r\nCreated on 2018-08-09 by the [reprex\r\npackage](http://reprex.tidyverse.org) (v0.2.0)."}}
{"actor":{"display_login":"dpseidel"}}