From b54cc10f9e4b8c8c22c7a6256302fc6dd968366b Mon Sep 17 00:00:00 2001 From: olivroy <52606734+olivroy@users.noreply.github.com> Date: Wed, 3 Jan 2024 17:57:04 -0500 Subject: [PATCH] Update topics.Rmd --- topics.Rmd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/topics.Rmd b/topics.Rmd index 6456a8f..f9799e3 100644 --- a/topics.Rmd +++ b/topics.Rmd @@ -204,7 +204,7 @@ library(scales) p <- ggplot(txhousing, aes(date, median)) + geom_line(aes( group = city, - text = paste("median:", number_si(median)) + text = paste("median:", label_number(scale_cut = cut_short_scale())(median) )) ggplotly(p, tooltip = c("text", "x", "city")) ``` @@ -229,10 +229,10 @@ length(w$x$data) # use the `y` attribute of the smooth line # to generate a custom string (to appear in tooltip) -text_y <- number_si( - w$x$data[[2]]$y, +text_y <- label_number( + scale_cut = cut_short_scale(), prefix = "Typical median house price: $" -) +)(w$x$data[[2]]$y) # suppress the tooltip on the raw time series # and supply custom text to the smooth line @@ -1090,4 +1090,4 @@ ggplotly(p) %>% hide_legend() knitr::include_graphics("images/xspline.svg") ``` -In more complicated cases, where your custom geom cannot be converted to a lower level geom, a custom method for the `geom2trace()` generic is required (`methods(geom2trace)` lists all the basic geoms that we natively support). This method should involve a conversion from a data frame to a list-like object conforming to the [plotly.js figure reference](https://plot.ly/r/reference). \ No newline at end of file +In more complicated cases, where your custom geom cannot be converted to a lower level geom, a custom method for the `geom2trace()` generic is required (`methods(geom2trace)` lists all the basic geoms that we natively support). This method should involve a conversion from a data frame to a list-like object conforming to the [plotly.js figure reference](https://plot.ly/r/reference).