{"id":13710971,"url":"https://allancameron.github.io/geomtextpath/","last_synced_at":"2025-05-06T20:31:29.596Z","repository":{"id":38412376,"uuid":"426753340","full_name":"AllanCameron/geomtextpath","owner":"AllanCameron","description":"Create curved text paths in ggplot2","archived":false,"fork":false,"pushed_at":"2024-03-12T13:39:12.000Z","size":63892,"stargazers_count":618,"open_issues_count":27,"forks_count":24,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-05-02T17:05:10.266Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://allancameron.github.io/geomtextpath","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AllanCameron.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-11-10T19:40:43.000Z","updated_at":"2024-06-13T07:40:10.248Z","dependencies_parsed_at":"2024-03-13T12:46:37.762Z","dependency_job_id":null,"html_url":"https://github.com/AllanCameron/geomtextpath","commit_stats":{"total_commits":677,"total_committers":108,"mean_commits":6.268518518518518,"dds":0.5096011816838996,"last_synced_commit":"ef1f12a96fe9b92da3b57726e92e1a037e61c523"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AllanCameron%2Fgeomtextpath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AllanCameron%2Fgeomtextpath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AllanCameron%2Fgeomtextpath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AllanCameron%2Fgeomtextpath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AllanCameron","download_url":"https://codeload.github.com/AllanCameron/geomtextpath/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224528315,"owners_count":17326339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T23:01:02.831Z","updated_at":"2024-11-13T21:31:22.044Z","avatar_url":"https://github.com/AllanCameron.png","language":"R","funding_links":[],"categories":["Plot layers"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  fig.align = \"center\",\n  dev = \"ragg_png\", # \u003c- prevent default Windows device to render plots\n  dpi = 132\n)\n\nlibrary(geomtextpath)\n```\n\n# geomtextpath \u003cimg src='man/figures/logo.png' align=\"right\" height=\"137\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/geomtextpath)](https://CRAN.R-project.org/package=geomtextpath)\n[![R-CMD-check](https://github.com/AllanCameron/geomtextpath/workflows/R-CMD-check/badge.svg)](https://github.com/AllanCameron/geomtextpath/actions)\n[![Codecov test coverage](https://codecov.io/gh/AllanCameron/geomtextpath/branch/main/graph/badge.svg)](https://app.codecov.io/gh/AllanCameron/geomtextpath?branch=main)\n[![metacran downloads](https://cranlogs.r-pkg.org/badges/geomtextpath)](https://cran.r-project.org/package=geomtextpath)\n\u003c!-- badges: end --\u003e\n\n## Create curved text in ggplot2\n\nThe existing text-based geom layers in ggplot2 (`geom_text` and `geom_label`) are ideal for the majority of plots, since typically textual annotations are short, straight and in line with the axes. However, there are some occasions when it is useful to have text follow a curved path. This may be to create or recreate a specific visual effect, or it may be to label a circular / polar plot in a more \"natural\" way. Direct and automatic text labels that adhere to their associated line can also provide a neat alternative to legends, without the need for specifying exact label positions, and with a lower risk of overplotting. \n\nUsing geomtextpath, your text can follow any path, and will remain correctly spaced and angled, even if you change the size and aspect ratio of your plotting device. It does so without the need to redraw your plot each time, as shown in the [introduction](https://allancameron.github.io/geomtextpath/articles/geomtextpath.html) vignette.\n\n## Installation\n\nYou can install geomtextpath from CRAN using\n\n```{r CRAN, eval=FALSE}\ninstall.packages(\"geomtextpath\")\n\n```\n\nAlternatively, you can install the latest development version of geomtextpath from [GitHub](https://github.com/) with:\n\n```{r github, eval=FALSE}\nremotes::install_github(\"AllanCameron/geomtextpath\", quiet = TRUE)\n```\n## Using **geomtextpath**\n\nOnce installed, we simply call:\n\n```{r library, eval=FALSE}\nlibrary(geomtextpath)\n#\u003e Loading required package: ggplot2\n```\n\nThe core functions in this package, `geom_textpath` and `geom_labelpath`, work like any other `geom` in `ggplot2`. They take their x co-ordinates, their y co-ordinates and their text label from an aesthetic mapping. At its most basic, this allows the `label` to be plotted on an arbitrary path, as shown in the following example:\n\n```{r spiral}\n# Set a consistent theme for the plots here\ntheme_set(theme_minimal() + \n          theme(axis.line = element_line(linewidth = 0.25, colour = \"gray75\")))\n\nt \u003c- seq(5, -1, length.out = 1000) * pi\n\nspiral \u003c- data.frame(x    = sin(t) * 1:1000, \n                     y    = cos(t) * 1:1000,\n                     text = paste(\"Like a circle in a spiral,\",\n                                  \"like a wheel within a wheel,\",\n                                  \"never ending or beginning,\",\n                                  \"on an ever spinning reel\")\n                     )\n\nggplot(spiral, aes(x, y, label = text)) +\n  geom_textpath(size = 7, vjust = 2, text_only = TRUE) +\n  coord_equal(xlim = c(-1500, 1500), ylim = c(-1500, 1500))\n```\n\nIf we want our text in a box, even when the text is curved, we can use `geom_labelpath` instead:\n\n```{r intro_label}\n\nset.seed(5)\nx  \u003c- runif(5)\ny  \u003c- runif(5)\ndf \u003c- data.frame(x = spline(1:5, x, xout = seq(1, 5, 1/100))$y,\n                 y = spline(1:5, y, runif(5), xout = seq(1, 5, 1/100))$y,\n                 z = \"A curved textbox on an arbitrary path\")\n\nggplot(df, aes(x, y, label = z)) + \n  geom_labelpath(size = 5, fill = \"#F6F6FF\", hjust = 0.55) +\n  geom_point(data = data.frame(x = x, y = y, z = 1))\n\n```\n\nOf course, the point of this package is not to produce such graphical novelties, but to provide an easy and visually appealing way to present your data. Just as `geom_path` is the foundation for several other geoms in `ggplot2`, so too are `geom_textpath` and `geom_labelpath` the foundation of the other geoms in this package. The line-based geoms in `ggplot` all have two equivalents in this package:\n\n| **ggplot geom**  | **Text equivalent**  | **Label equivalent**   |\n|:-----------------|:---------------------|:-----------------------|\n| `geom_path`      | `geom_textpath`      | `geom_labelpath`       |\n| `geom_segment`   | `geom_textsegment`   | `geom_labelsegment`    |\n| `geom_line`      | `geom_textline`      | `geom_labelline`       |\n| `geom_abline`    | `geom_textabline`    | `geom_labelabline`     |\n| `geom_hline`     | `geom_texthline`     | `geom_labelhline`      |\n| `geom_vline`     | `geom_textvline`     | `geom_labelvline`      |\n| `geom_curve`     | `geom_textcurve`     | `geom_labelcurve`      |\n| `geom_density`   | `geom_textdensity`   | `geom_labeldensity`    |\n| `geom_smooth`    | `geom_textsmooth`    | `geom_labelsmooth`     |\n| `geom_contour`   | `geom_textcontour`   | `geom_labelcontour`    |\n| `geom_density2d` | `geom_textdensity2d` | `geom_labeldensity2d`  |\n| `geom_sf`        | `geom_textsf`        | `geom_labelsf`         |\n\nEach of these aims to replicate all the functionality of the equivalent `ggplot2` function, but with direct text labels that follow the shape of the lines drawn.\n\nFor the special case of `geom_sf`, which draws different shapes based on the geometry objects drawn, the equivalent `geom_textsf` and `geom_labelsf`, will identify and label the linestring components (typically rivers and roads), without attempting to label polygons.\n\n### `geom_textline` and `geom_labelline`\n\nYou can use `geom_textline` and `geom_labelline` as a drop in for `geom_line` if you want it directly labelled. Just pass the `label` you want as an argument to `geom_textline` (or if you have grouped data, you can pass the label as an aesthetic mapping). As in the other geoms here, you can specify the line's appearance and the text's appearance separately.\n\n```{r textline_demo}\nggplot(pressure, aes(temperature, pressure)) +\n  geom_textline(label = \"Mercury vapor pressure\", size = 6, vjust = -0.5,\n                linewidth = 1, linecolor = \"red4\", linetype = 2, \n                color = \"deepskyblue4\")\n```\n\n### `geom_textdensity` and `geom_labeldensity`\n\nThese are the analogues of `geom_density` that allows for smoothly curved labels on density plots\n\n```{r density_demo}\nggplot(iris, aes(x = Sepal.Length, colour = Species, label = Species)) +\n  geom_textdensity(size = 6, fontface = 2, hjust = 0.2, vjust = 0.3) +\n  theme(legend.position = \"none\")\n```\n\nNote that we have been able to \"reclaim\" the space normally taken up by the legend without leaving any ambiguity in the plot.\n\n### `geom_textsmooth` and `geom_labelsmooth`\n\nWe can use these geoms to get labelled trend lines through scatterplots:\n\n```{r smooth}\nggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color = Species)) +\n  geom_point(alpha = 0.3) +\n  geom_labelsmooth(aes(label = Species), text_smoothing = 30, fill = \"#F6F6FF\",\n                method = \"loess\", formula = y ~ x,\n                size = 4, linewidth = 1, boxlinewidth = 0.3) +\n  scale_colour_manual(values = c(\"forestgreen\", \"deepskyblue4\", \"tomato4\")) +\n  theme(legend.position = \"none\")\n```\n\nNote that by design, we have not included the standard error ribbon in these geoms because the naming of the `fill` aesthetic would clash with the fill of the text boxes. If necessary, a standard `geom_smooth` can be drawn first to obtain the ribbon.\n\n\n### Labelled contour lines\n\nAdding labels to the level of your contour lines is now as simple as calling `geom_textcontour` or `geom_labelcontour` instead of `geom_contour`:\n\n```{r volcano}\n\ndf \u003c- expand.grid(x = seq(nrow(volcano)), y = seq(ncol(volcano)))\ndf$z \u003c- as.vector(volcano)\n\nggplot(df, aes(x, y, z = z)) + \n  geom_contour_filled(bins = 6, alpha = 0.6) + \n  geom_textcontour(bins = 6, size = 2.5, straight = TRUE) + \n  scale_fill_manual(values = terrain.colors(11)) + \n  theme(legend.position = \"none\")\n\n```\n\nWe also have `geom_textdensity2d` and `geom_labeldensity2d` for the common use case of 2D density contours:\n\n```{r density2d}\nset.seed(1)\n\ndf  \u003c- data.frame(x = rnorm(100), y = rnorm(100))\n\nggplot(df, aes(x, y)) + \n  geom_textdensity2d()\n\n```\n\n### `geom_textsf` and `geom_labelsf`\n\nThese geoms behave much the same way as `geom_sf`, except linestrings such as rivers and roads can be given (curved) text labels:\n```{r geom_textsf}\n\nlibrary(sf)\n\ndf \u003c- data.frame(x = c(-4.2518, -3.1883), \n                 y = c(55.8642, 55.9533),\n                 label = c(\"Glasgow\", \"Edinburgh\"))\n\nggplot(data = df) +\n  geom_textsf(data = waterways,\n              aes(label = name), text_smoothing = 65, linecolour = \"#8888B3\", \n              color = \"gray30\", vjust = -0.8, fill = \"#E6F0B3\", \n              alpha = 0.8, fontface = 3, size = 3) + \n  geom_point(aes(x, y), data = df, color = \"gray50\", size = 3) + \n  geom_textpath(aes(x, y, label = label), color = \"gray50\",\n                hjust = c(-0.2, 1.2)) +\n  theme(panel.grid = element_line()) + \n  lims(x = c(-4.7, -3), y = c(55.62, 56.25))\n\n```\n\n### Reference lines\n\nOften, a reference line added to a plot requires a text annotation. We can do this directly with `geom_textabline`, `geom_textvline` and `geom_texthline`, or their text-box equivalents `geom_labelabline`, `geom_labelvline` and `geom_labelhline`. Although such lines aren't curved, there are some benefits to using the `geomtextpath` functions if a labelled reference line is required: only a single call is needed, co-ordinates are not required for the text label, the text can be put in-line with an appropriate break in the line automatically, and the label will orientate and curve appropriately in polar co-ordinates.\n\nThis example shows all three text-based reference line geoms:\n\n```{r vline}\nggplot(mtcars, aes(mpg, disp)) + \n  geom_point() + \n  geom_texthline(yintercept = 200, label = \"displacement threshold\", \n                 hjust = 0.8, color = \"red4\") +\n  geom_textvline(xintercept = 20, label = \"consumption threshold\", hjust = 0.8,\n                 linetype = 2, vjust = 1.3, color = \"blue4\") +\n  geom_textabline(slope = 15, intercept = -100, label = \"partition line\", \n                  color = \"green4\", hjust = 0.6, vjust = -0.2)\n```\n\nIn addition to the straight reference lines, there is also a pair of geom layers for curved reference lines: `geom_textcurve` and `geom_labelcurve`. These are typically used for annotations.\n\n```{r curve}\ndf \u003c- data.frame(Activity = c(\"Work\", \"Play\"), Happiness = c(0.5, 0.7))\n\nggplot(df, aes(Activity, Happiness)) + \n  geom_col(fill = \"gold\", color = \"gray50\") + \n  geom_textcurve(data = data.frame(x = 1, xend = 2, y = 0.72, yend = 0.52), \n                 aes(x, y, xend = xend, yend = yend), hjust = 0.35, ncp = 20,\n                 curvature = -0.8, label = \"significant difference\") +\n  geom_point(aes(y = Happiness + 0.02)) +\n  scale_y_continuous(limits = c(0, 1))\n\n```\n\n### Arbitrary `stat` transformations\n\nOther \"stat\" transformations can be used directly on `geom_textpath` and `geom_labelpath`. For example, functions can be labelled with paths created in `stat_function`:\n\n```{r stat_function}\nggplot() + \n  xlim(c(0, 1)) + \n  stat_function(geom = \"textpath\",\n                fun = dgamma, color = \"red4\",\n                label = \"gamma distribution with shape = 1\",\n                size = 5, vjust = -0.2, hjust = 0.1, args = list(shape = 1)) +\n  stat_function(geom = \"textpath\",\n                fun = dgamma, color = \"blue4\",\n                label = \"gamma distribution with shape = 2\",\n                size = 5, vjust = -0.2, hjust = 0.1, args = list(shape = 2)) +\n  stat_function(geom = \"textpath\",\n                fun = dgamma, color = \"green4\",\n                label = \"gamma distribution with shape = 3\",\n                size = 5, vjust = -0.2, hjust = 0.1, args = list(shape = 3))\n```\n\n### Controlling text position\n\nJust like `geom_text`, the `vjust` parameter controls vertical justification of the text, though in `geom_textpath` and its related geoms, the text is justified relative to the path rather than a single point. If the `vjust` parameter moves the text above or below the line, the line is automatically \"filled in\". \n\nFor short text labels applied to long paths, we need a parameter to control how far along the path the text is placed. For this we use the horizontal justification (`hjust`) parameter. This can be numeric (0 to 1), or can accept position descriptions such as \"xmid\", \"ymax\", or \"auto\".\n\nHere is an example of text justified above the line of the path using a small negative value of `vjust`, and the `hjust` set to \"ymax\" to place the labels over the peak of each curve:\n\n```{r density_vjust}\np \u003c- ggplot(iris, aes(x = Sepal.Length, colour = Species, label = Species)) +\n       theme(legend.position = \"none\")\n\np + \n  geom_textdensity(size = 6, fontface = 2, spacing = 50,\n                   vjust = -0.2, hjust = \"ymax\") +\n  ylim(c(0, 1.3))\n```\n\nYou can read more about text positioning in the [aesthetics vignette](https://allancameron.github.io/geomtextpath/articles/aesthetics.html).\n\n### Smoothing text while preserving path details\n\nSome lines may be too \"noisy\" or too angular for direct labels to remain legible if they adhere too closely to the line. We have therefore added the ability to smooth the text label while keeping the path unaltered, using a `text_smoothing` parameter, which can be set from 0 (none) to 100 (maximum).\n\n```{r smooth2}\n\nggplot(economics, aes(date, unemploy)) +\n  geom_textline(linecolour = \"grey\", size = 4, vjust = -1.5,\n                label = \"1990s Decline\", text_smoothing = 30)\n```\n\n### `Plotmath` support\n\nIf you want to use plotmath expressions you can do so much as you would with `geom_text`. Just tell `geom_textpath` that your labels should be parsed using `parse = TRUE`\n\n``` {r plotmath}\nlab \u003c- expression(paste(\"y = \", frac(1, sigma*sqrt(2*pi)), \" \",\n                            plain(e)^{frac(-(x-mu)^2, 2*sigma^2)}))\n\ndf \u003c- data.frame(x = seq(-2, 0, len = 100),\n                 y = dnorm(seq(-2, 0, len = 100)),\n                 z = as.character(lab))\n\nggplot(df, aes(x, y)) + \n  geom_textpath(aes(label = z), vjust = -0.2, hjust = 0.1, size = 8, parse = TRUE)\n\n```\n\nNote that, due to the way the `grid` package draws plotmath expressions, all plotmath labels will be straight rather than curved. However, as in the example above, they will still be angled according to the gradient of the curve.\n\n### Rich text support\n\nThe geoms here also feature richtext support. If you want your text labels to be interpreted as rich text, simply pass `rich = TRUE` as a parameter in the call to the geom layer\n\n```{r richtext}\n\nlab \u003c- paste(\"\u003cspan style='color:gray30;font-size:10pt'\u003ePlasma\u003c/span\u003e\",\n             \"\u003cstrong style='color:red4;font-size:10pt'\u003eIndometacin\u003c/strong\u003e\",\n             \"\u003cspan style ='color:gray30;font-size:10pt'\u003eConcentration \u003c/span\u003e\",\n             \"\u003ci style='color:gray50;font-size:8pt'\u003e\u003csub\u003e(\\u03BCg/l)\u003c/sub\u003e\u003c/i\u003e\")\n\nggplot(Indometh, aes(time, conc, group = 1)) + \n  geom_textsmooth(formula = y ~ x, method = loess, \n                  label = lab, rich = TRUE, vjust = -0.5, size = 4.5, \n                  text_smoothing = 40, linecolor = \"red4\") + \n  xlim(c(0, 4))\n\n```\n\n### Text paths in polar coordinates\n\nStraight text paths in Cartesian coordinates become curved in polar coordinates.\n\n```{r coords_cartesian}\ndf \u003c- data.frame(x = c(1, 1000), y = 1, text = \"This is a perfectly flat label\")\n\np \u003c- ggplot(df, aes(x, y, label = text)) +\n  geom_labelpath(size = 6, text_only = TRUE, fill = \"#F6F6FF\") +\n  ylim(c(0.9, 1.1))\n\np\n```\n\n```{r coords_polar}\np + coord_polar()\n```\n\nWe have included the ability to have _point-like_ text paths. While this sounds paradoxical, it means that `geom_textpath` can be used as a drop-in for `geom_text`, and will behave in much the same way, with the exception that the text will automatically curve in polar co-ordinates. Compare `geom_textpath` used in Cartesian co-ordinates:\n\n```{r pointlike}\ndf \u003c- data.frame(x = 1:4, y = c(4, 7, 6, 3),\n                 color = c(\"royalblue\", \"orangered\", \"deepskyblue4\", \"violet\"))\n\np \u003c- ggplot(df, aes(x, y, color = color, label = color)) +\n       geom_point(size = 1.5) +\n       geom_textpath(size = 8, hjust = -0.1) +\n       scale_color_identity() +\n       lims(x = c(0, 6), y = c(0, 8)) \n\np\n\n```\n\nAnd in polar co-ordinates:\n\n```{r polar_compare}\np + coord_polar()\n```\n\nBy default, any labels that would have been upside down (or even mostly upside down) are automatically flipped to be facing in a legible direction. This can be turned off using `upright = FALSE` in the call to `geom_textpath`.\n\nWe can even construct diagrams or infographics:\n\n```{r fancy_cartesian}\np \u003c- data.frame(x1 = c(seq(0, 10/6 * pi, pi/3),\n                  seq(0, 10/6 * pi, 2*pi/3)),\n           y1 = c(rep(2, 6), rep(-1, 3)),\n           x2 = c(seq(0, 10/6 * pi, pi/3)  + pi/3,\n                  seq(0, 10/6 * pi, 2*pi/3) + 2*pi/3),\n           y2 = c(rep(4, 6), rep(2, 3)),\n           group = letters[c(1:6, (1:3) * 2)],\n           alpha = c(rep(1, 6), rep(0.4, 3))) |\u003e\n  ggplot(aes(x1, y1)) +\n  geom_rect(aes(xmin = x1, xmax = x2, ymin = y1, ymax = y2, fill = group,\n                alpha = alpha),\n            color = \"white\", linewidth = 2) +\n  geom_textpath(data = data.frame(x1 = seq(0, 2 * pi, length = 300),\n           y1 = rep(0.5, 300),\n           label = rep(c(\"stats\", \"effects\", \"polar\"), each = 100)),\n           aes(label = label), linetype = 0, size = 8,\n           upright = TRUE) +\n  geom_textpath(data = data.frame(x1 = seq(0, 2 * pi, length = 300),\n           y1 = rep(3, 300),\n           label = rep(c(\"density\", \"smooth\", \"unique\", \"organic\",\n                         \"easy to use\", \"automatic\"), \n                       each = 50)),\n           aes(label = label), linetype = 0, size = 4.6, color = \"white\",\n           upright = TRUE) +\n  scale_y_continuous(limits = c(-5, 4)) +\n  scale_x_continuous(limits = c(0, 2*pi)) +\n  scale_fill_manual(values = c(\"deepskyblue3\", \"deepskyblue4\",\n                               \"green3\", \"green4\",\"tomato\", \"tomato2\")) +\n  scale_alpha_identity() +\n  theme_void() +\n  theme(legend.position = \"none\") \n\np\n```\n\nThat flip nicely to polar co-ordinates.\n\n```{r fancy_polar}\n\np + coord_polar()\n\n```\n\n\n## `coord_curvedpolar`\n\nAnother function exported from this package is `coord_curvedpolar`. This behaves identically to `coord_polar`, except that the circumferential axis labels are curved. For example:\n\n```{r coord_curvedpolar}\nclock \u003c- function(x) {\n  \n  hours \u003c- c(rep(x[1] %% 12 + tail(x, 1) / 60, 2), 0, 3.5)\n  minutes \u003c- c(rep(tail(x, 1)/5, 2), 0, 5)\n\n  ggplot(as.data.frame(rbind(hours, minutes)), aes(V1, V3)) + \n      geom_segment(aes(xend = V2, yend = V4), \n                   linewidth = c(3, 2), lineend = \"round\") +\n      geom_point(x = 0, y = 0, size = 6) +\n      scale_x_continuous(limits = c(0, 12), breaks = 1:12,\n                         label = as.roman) +\n      scale_y_continuous(limits = c(0, 6), expand = c(0, 0)) +\n      theme_void() + \n      theme(axis.text.x = element_text(size = 25, face = 2),\n            plot.margin = margin(20, 20, 20, 20))\n}\n\nclock(19:15) + coord_curvedpolar()\n```\n\nThis can be useful to achieve a particular aesthetic effect (as above), but can also be of practical utility when axis labels are long, which can produce some problems in standard `coord_polar`:\n\n```{r coord_curvedpolar2}\ndf \u003c- data.frame(x = c(\"A long axis label\", \"Another long label\",\n                       \"The longest label of all\", \"Yet another label\"),\n                 y = c(8, 6, 10, 4))\n\np \u003c- ggplot(df, aes(x, y, fill = x)) + \n      geom_col(width = 0.5) +\n      scale_fill_brewer(type = \"qual\") +\n      theme(axis.text.x = element_text(size = 15),\n            legend.position = \"none\")\n\np + coord_curvedpolar()\n```\n\n\n## Tips\n\nNot every graphics device renders text equally well. In particular, the default Windows graphics device makes text look horrible, especially when placed on paths. To get the best looking results for raster graphics, we recommend the [{ragg}](https://ragg.r-lib.org/) package.\n\n## Limitations\n\nThere are limitations inherent in the plotting of text elements in ggplot due to the way that the underlying `grid` graphics handles text. A text string is dealt with as a zero-width object, and therefore the rotation and spacing of the letters making up the string can only be dealt with by treating each letter separately. \n\nIt is important to realise that the letters are only rotated, and do not undergo any change in shape. Thus, for example, large text appearing on convex curves will not be deformed so that individual letters are narrower at the bottom and wider at the top. Doing so would require reinterpreting the letters as polygons, which would likely cause more problems than it would solve.\n\nOther paths may have points of tight curvature, and setting an `offset` / `vjust` for the text that is larger than the distance to the focus point of that curve will produce odd effects. The package tries to detect and warn the user when this happens, and will suggest remedies.\n\n### Acknowledgments\n\nThe authors would like to thank [Patrick Plenefisch](https://github.com/byteit101) for posting the [Stackoverflow question](https://stackoverflow.com/questions/69867669/is-there-way-in-ggplot2-to-place-text-on-a-curved-path) that prompted them to develop this package, and for raising some important issues early in its development. \n\nOf course this package wouldn't be possible without the brilliant [ggplot2](https://github.com/tidyverse/ggplot2) package. Although we're grateful to all the developers on the tidyverse team for creating and maintaining such useful open-source software, we'd like to give particular thanks to [Claus Wilke](https://github.com/clauswilke) for also creating the excellent [gridtext](https://wilkelab.org/gridtext/) package from which `geomtextpath` borrows, and [Thomas Lin Pedersen](https://github.com/thomasp85), whose [textshaping](https://github.com/r-lib/textshaping) package was integral to getting the mechanism working.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/allancameron.github.io%2Fgeomtextpath%2F","html_url":"https://awesome.ecosyste.ms/projects/allancameron.github.io%2Fgeomtextpath%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/allancameron.github.io%2Fgeomtextpath%2F/lists"}