How can I show values on my plot with plot_summs as well?
- User
How can I show values on my plot with plot_summs as well?
Assistant
Great question! You're already using the argument
show.values = TRUEin yourjtools::plot_summs()call, which is the correct way to display coefficient values on the plot.However, sometimes people want more control over how those values are displayed—like changing their format, position, or rounding. Let's walk through what you can do:
✅ Basic Use: Show Values
You’re already doing this correctly:
jtools::plot_summs(model_reg_ratio, scale = TRUE, exp = TRUE, show.values = TRUE)This will place the coefficient value near each point estimate on the plot.
🛠️ Customize Value Display with
values_formatIf you want to format the numbers, use the
values_formatargument. This works likesprintf()formatting in R.Example 1: Round to 2 decimal places
jtools::plot_summs(model_reg_ratio, scale = TRUE, exp = TRUE, show.values = TRUE, values_format = "%.2f")Example 2: Format as percentage (if appropriate)
jtools::plot_summs(model_reg_ratio, scale = TRUE, exp = TRUE, show.values = TRUE, values_format = "%.1f%%")⚠️ Note: This only affects how the values are shown — not the actual plotted values.
📏 Adjusting Position of Value Labels
By default, the labels appear just to the right of the dot. If you find them overlapping or misplaced, you can adjust the position relative to the dot using
value_offset.Example: Move labels a bit further from the dot
jtools::plot_summs(model_reg_ratio, scale = TRUE, exp = TRUE, show.values = TRUE, value_offset = 0.15) # Increase if neededYou may need to tweak this depending on your axis limits and number of variables.
🎨 Style Value Labels (Color, Size, etc.)
Since
plot_summs()returns aggplotobject, you can modify the appearance of the value labels after plotting using standardggplot2syntax.Example: Change label size and color
library(ggplot2) p <- jtools::plot_summs(model_reg_ratio, scale = TRUE, exp = TRUE, show.values = TRUE) p + geom_text(aes(label = sprintf("%.2f", exp Estimate)), data = p$data, hjust = -0.2, # move label to the right size = 3, color = "blue")🔍 Tip: If you're using
exp = TRUE, make sure the labels reflect exponentiated values by working directly with the transformed data.
🧩 Full Customized Example
Here’s a full example combining all the above:
library(jtools) library(ggplot2) p <- plot_summs(model_reg_ratio, scale = TRUE, exp = TRUE, show.values = TRUE, values_format = "%.2f", value_offset = 0.15) + labs(x = "Multiplicative Change in Trust Ratio (trustEU/trustUK)") + scale_x_continuous(breaks = seq(0.5, 2, 0.5), limits = c(0.4, 2.1)) # Optional: Further customize label appearance p <- p + geom_text(aes(label = sprintf("%.2f", exp(Estimate))), data = p$data, hjust = -0.2, size = 3.5, color = "darkred") print(p)
Summary
Goal Argument / Method Show values show.values = TRUEFormat values values_format = "%.2f"Move values farther value_offset = 0.15Customize appearance Add geom_text()manuallyLet me know if you'd like to add significance stars or combine this with other visualizations!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.