Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3721688
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:38:34+00:00 2026-05-19T05:38:34+00:00

I have the following problem: I would like to visualize a discrete and a

  • 0

I have the following problem: I would like to visualize a discrete and a continuous variable on a boxplot in which the latter has a few extreme high values. This makes the boxplot meaningless (the points and even the “body” of the chart is too small), that is why I would like to show this on a log10 scale. I am aware that I could leave out the extreme values from the visualization, but I am not intended to.

Let’s see a simple example with diamonds data:

m <- ggplot(diamonds, aes(y = price, x = color))

alt text

The problem is not serious here, but I hope you could imagine why I would like to see the values at a log10 scale. Let’s try it:

m + geom_boxplot() + coord_trans(y = "log10")

alt text

As you can see the y axis is log10 scaled and looks fine but there is a problem with the x axis, which makes the plot very strange.

The problem do not occur with scale_log, but this is not an option for me, as I cannot use a custom formatter this way. E.g.:

m + geom_boxplot() + scale_y_log10() 

alt text

My question: does anyone know a solution to plot the boxplot with log10 scale on y axis which labels could be freely formatted with a formatter function like in this thread?


Editing the question to help answerers based on answers and comments:

What I am really after: one log10 transformed axis (y) with not scientific labels. I would like to label it like dollar (formatter=dollar) or any custom format.

If I try @hadley’s suggestion I get the following warnings:

> m + geom_boxplot() + scale_y_log10(formatter=dollar)
Warning messages:
1: In max(x) : no non-missing arguments to max; returning -Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In max(x) : no non-missing arguments to max; returning -Inf

With an unchanged y axis labels:

alt text

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:38:35+00:00Added an answer on May 19, 2026 at 5:38 am

    The simplest is to just give the ‘trans’ (formerly ‘formatter’) argument of either the scale_x_continuous or the scale_y_continuous the name of the desired log function:

    library(ggplot2)  # which formerly required pkg:plyr
    m + geom_boxplot() + scale_y_continuous(trans='log10')
    

    EDIT:
    Or if you don’t like that, then either of these appears to give different but useful results:

    m <- ggplot(diamonds, aes(y = price, x = color), log="y")
    m + geom_boxplot() 
    m <- ggplot(diamonds, aes(y = price, x = color), log10="y")
    m + geom_boxplot()
    

    EDIT2 & 3:
    Further experiments (after discarding the one that attempted successfully to put "$" signs in front of logged values):

    # Need a function that accepts an x argument
    # wrap desired formatting around numeric result
    fmtExpLg10 <- function(x) paste(plyr::round_any(10^x/1000, 0.01) , "K $", sep="")
    
    ggplot(diamonds, aes(color, log10(price))) + 
      geom_boxplot() + 
      scale_y_continuous("Price, log10-scaling", trans = fmtExpLg10)
    

    alt text

    Note added mid 2017 in comment about package syntax change:

    scale_y_continuous(formatter = ‘log10’) is now scale_y_continuous(trans = ‘log10’) (ggplot2 v2.2.1)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem: I would like to change value of ExpandableListView's cell
Following problem: I would like to build a little clipboard with jQuery. I have
I have the following problem: I would like to use footnotes together with the
I am stuck with this following problem. Say, I have a request which has
I have the following problem. If I query values with a keyfigure which is
I have got the following problem since the server has safe mode turned on,
Has anyone encountered the following problem: I have IIS7 running on my computer. On
I have a PyQt program used to visualize some python objects. I would like
I have the following problem: I have an HTML textbox ( <input type=text> )
I have the following problem using subversion: I'm currently working on the trunk of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.