Skip to content
TheChatArchiveThe Chat Archive
Qwenqwen3-235b-a22b-no-thinking· Alibaba (Qwen)Hugging Face LMArena Human Preference 140K

How can I show values on my plot with plot_summs as well?

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Mistralmistral-medium-2505’s answer.
  1. User

    How can I show values on my plot with plot_summs as well?

  2. Qwen Assistant

    Great question! You're already using the argument show.values = TRUE in your jtools::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_format

    If you want to format the numbers, use the values_format argument. This works like sprintf() 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 needed
    

    You may need to tweak this depending on your axis limits and number of variables.


    🎨 Style Value Labels (Color, Size, etc.)

    Since plot_summs() returns a ggplot object, you can modify the appearance of the value labels after plotting using standard ggplot2 syntax.

    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

    GoalArgument / Method
    Show valuesshow.values = TRUE
    Format valuesvalues_format = "%.2f"
    Move values farthervalue_offset = 0.15
    Customize appearanceAdd geom_text() manually

    Let me know if you'd like to add significance stars or combine this with other visualizations!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.