Closed Thread
Results 1 to 8 of 8

Log-scale histograms

Hybrid View

  1. #1
    Registered User
    Join Date
    12-12-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    3

    Log-scale histograms

    I have a numeric variable that is roughly log-normally distributed and would like to plot it in a log-scaled histogram. I'm using the histogram feature of the Analysis Toolpak add-in to 2010.

    I couldn't see an option to directly set a log-scale (did I miss one?) so I created a new variable that was the natural log of my original variable and drew a histogram of that instead. The bars themselves are fine (though I had to manually remove the gap between the bars via Right click, Format Data Series... -> Series Options) but the labels belong to the log-scale variable. This is as you would expect, but not what I want.

    How do I override the axis labels with the ones on the natural scale?

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Log-scale histograms

    Right-click the axis, Format Axis, tick Logarithmic Scale
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-12-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Log-scale histograms

    Quote Originally Posted by shg View Post
    Right-click the axis, Format Axis, tick Logarithmic Scale
    Thanks. Unfortunately, I can do right click and 'Format Axis...' but then there is no obvious option for a logarithmic scale.

    excel histogram format axis.PNG

    I've hunted through all the tabs in that dialog box, but couldn't find anything suitable. Where is the option for logarithmic scale?

    EDIT: The MS help page for changing axis scales doesn't mention logarithms either.
    http://office.microsoft.com/en-us/wo...010342254.aspx

    EDIT2: It seems that I can set a log scale on the vertical axis.

    excel vertical axis log scale.PNG

    Any idea how to get this option for the horizontal axis too?
    Last edited by richierocks; 12-13-2012 at 04:41 AM. Reason: added image of vertical axis options

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Log-scale histograms

    That's the x axis for a line chart. I assumed you wanted the y axis for a scatter chart (which probably works for a line chart as well, haven't tried), but for the x axis, it MUST BE a scatter chart.

    Change the chart type.

  5. #5
    Registered User
    Join Date
    12-12-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Log-scale histograms

    Quote Originally Posted by shg View Post
    but for the x axis, it MUST BE a scatter chart. Change the chart type.
    Thanks again. As the title of the thread suggests, I'm trying to draw a histogram, not a scatterplot. (Since I'm trying to visualise the distribution of a single variable, not compare two variables, a scatterplot isn't appropriate.)

    As Microsoft, in their wisdom, have deemed log transformations of the x axis unneccessary, I suppose a hack is in order. So, it possible to either

    1. Hack one of the other chart types to display histograms bars? The scatterplot chart definitely do log-x-scales but can it display bars? The barplot chart type can obviously display bars, but will it allow for a continuous variable on the x-axis?

    2. Plot a histogram of the log-transformed variable and override the axis labels with natural scale values, as I first suggested?

  6. #6
    Registered User
    Join Date
    01-02-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    1

    Re: Log-scale histograms

    I appreciate this is a very old thread, but for the benefit of others looking for a solution to this:

    You can use the FREQUENCY function to bin your data into whatever chunks you need to, with the syntax being =FREQUENCY(data_array, bins_array). Your bins array will contain the lower bounds of the bin, for example if the first couple of cells are 20,21,22... then the first row of your results will show the frequency of a value between 20-21, the next 21-22 etc.

    Information about the usage of this function can be found online, but in short if you have your data to be binned in cells A1:A100 then you just need to create your bins array (e.g. in cells B1:B30), then highlight cells C1:C30 and type in the FREQUECNY function then press CTRL+Shift+Enter to complete the operation.

    I then use a helper column to contain the upper bound value of the bin (simply by referencing the next value in the bin array), then use a concatenate function to create a reasonable value for the x axis of your plot - e.g. if your lower bound value is in cell B1:B30 and the upper bound is in D1:D30, then in cells E1:E30 you will write something like =CONCATENATE(B1," - ",D1).

    From here, a simple bar chart can be used which will allow a log scale be selected as described in this thread.

    Hope this helps someone.

  7. #7
    Registered User
    Join Date
    07-14-2021
    Location
    Cambridge, Massachusetts
    MS-Off Ver
    16.49
    Posts
    1

    Re: Log-scale histograms

    I'm confused by this: how does creating the helper column and using the concatenate function work to allow a log scale to be used in the bar chart?

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,569

    Re: Log-scale histograms

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1