+ Reply to Thread
Results 1 to 10 of 10

Stacked Histogram?

  1. #1
    Registered User
    Join Date
    09-22-2016
    Location
    California, USA
    MS-Off Ver
    2016 Excel
    Posts
    7

    Stacked Histogram?

    Hi,

    I have a data-set that I am trying to make a "stacked histogram" for.

    Say you are manufacturing a bunch of screws. You have three different types of machines making these screws (Type 1, Type 2, and Type 3). Now, you want to see how often a screw is made with a specific length.

    I want the x-axis to hold a range of values for screw size with a specified bin size (ie: screw lengths that fall between 20-22mm, 22-24mm, etc).
    On the y-axis I want to keep a count of # of instances (ie: 10 total screws were made that were 20-22mm long).

    However, I want to maintain the ability to see how many screws of each length each "type" of machine contributed to the total made (ie: for the 10 total screws made that were 20-22mm long, Type 1 made 7 of those, Type 2 made 2, and Type 3 made 1).

    Thanks for the help.
    2016-09-22-17-37-03-6289.jpg

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Stacked Histogram?

    A histogram is basically a column chart with specific formatting (no gaps between columns). So a "stacked histogram" will be a stacked column chart with specific formatting. This is for 2007, but the basics of data layout and such should still be the same in 2016, and all of the formatting commands should still be present somewhere. https://support.office.com/en-us/art...0-e9ab353c4c00

    Let us know where you get stuck.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    09-22-2016
    Location
    California, USA
    MS-Off Ver
    2016 Excel
    Posts
    7

    Re: Stacked Histogram?

    Thanks for the prompt reply MrShorty.

    I played around earlier with a stacked column chart. I looked through the link that you sent, but those changes all seemed to be cosmetic. Specifically, I want the x-axis to encompass a range (say 20-22mm). Each time a data entry falls between that range, another entry of type "Type 1, 2, 3" is added to that column. I could pre-order the data and manually input the number of times values fall between specific ranges (and then make this stacked chart), but I'm dealing with a couple hundred points, so having excel do the grunt work for me would be nice

  4. #4
    Registered User
    Join Date
    09-22-2016
    Location
    California, USA
    MS-Off Ver
    2016 Excel
    Posts
    7

    Re: Stacked Histogram?

    To expand on this a little further.. with the stacked column chart Excel is plotting cumulative length on the y-axis. I have 25 rows worth of data. Within each row, it is summing up the values in each column and showing the total contribution of each type of machine to that cumulative length.

    Instead, I would like the y-axis to have the number of times a screw falls between a range specified on the x-axis. I felt like a histogram better encompassed this notion, however I couldn't get those values to "stack" and show the total contribution to the whole of each machine type.
    With the stacked column chart, it succeeds in showing total contribution to the whole for each type, but the "type" is length (as opposed to machine type) and the x-axis is row #.

    I'm thinking that I may have to run an excel formula beforehand to organize things in a way that it likes - my Excel exposure is limited though as I have never explicitly enjoyed using it and as such I'm not a guru.
    Last edited by jgodfrey; 09-23-2016 at 12:14 PM.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Stacked Histogram?

    Your observation is correct, that the help file demonstrates a lot of cosmetic formatting. However, data layout in the spreadsheet is often a key part of creating stacked charts, and MS's example shows how to arrange the data in the spreadsheet. Did you take notice of how they arranged the data in the example (territory down the left column, quarter across the top, values in the body of the table)? I would expect something just like that for your data. If you match MS's example, you will have screw length down the left of your table, machine type across the top, contribution in the body of the table.

    With the stacked column chart, it succeeds in showing total contribution to the whole for each type, but the "type" is length (as opposed to machine type) and the x-axis is row #.
    This sounds like you may have made a good attempt, but Excel misread your desired series assignments on chart creation (Excel has a bad habit of this). After creating the chart, did you go into the Source Data dialog to see what ranges Excel assigned to each value series, the horizontal axis series, etc.? I find that I must frequently go into this dialog to correct Excel's misunderstandings.

  6. #6
    Registered User
    Join Date
    09-22-2016
    Location
    California, USA
    MS-Off Ver
    2016 Excel
    Posts
    7

    Re: Stacked Histogram?

    I used the format type specified above.

    The x and y axis are still not correctly representing what I truly want.
    I'll attach the data on this post. I am giving Excel a lot less information than I should be.

    y-axis should contain whole integers representative of a claim saying "10 screws were made that were within this range". The x-axis should contain that range (20-22mm or whatever it is). Ultimately, I would be able to make a claim saying.. "10 screws were made within 20-22mm, 7 within 22-24mm etc etc". The importance of the stacking is that I can see how each specific machine contributes to the total number of screws made within that range.

    Thanks, I don't think I've ever spent this long trying to make a silly graph...

    PS: couldn't attach the Excel file for some reason - so sent it via pictureexample.JPG

    Conversely, a histogram gives the correct x and y axis. However, even with all data selected, it only graphs one column of data - the other columns are hidden behind it.
    Note that the y axis is counting the number of times a value (in this case of type 1) falls between the ranges on the x axis. If I change those x axis ranges in the excel options, the y axis count changes accordingly. This is exactly what I want, but I want to stack all of the machine Types! frustrating stuff
    example2.JPG
    Last edited by jgodfrey; 09-23-2016 at 01:22 PM.

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Stacked Histogram?

    PS: couldn't attach the Excel file for some reason - so sent it via picture
    A picture is usually harder to debug from. I don't know what is up with the various uploader options on this site, but a lot of people have trouble. I do not know how you tried to upload. The only reliable upload method I have used here is to click on reply to thread or go advanced. Below the post editor is a "manage attachments" link that opens up the file uploader in another window/tab. See if that will allow you to upload a sample.

    Looking at your pictures, I must not be understanding what you want to do. I thought you already had all the data you needed in the spreadsheet, so that the stacked column chart in the picture would be what you wanted.

    One way or another, you appear to understand the mechanics of creating the stacked column chart. At this point, it appears that you have not yet calculated the data that you want to appear in your stacked column chart. It seems to me that, once you figure out how to calculate the desired values, you will be able to create the stacked column chart just fine.

    Trying to reverse engineer how you got the histogram from the above data -- It looks like your histogram is counting the number of entries in Type1 column that fits in each bin. How are you generating this histogram -- from the histogram tool on the data anlysis menu, or are you using the FREQUENCY() [or COUNTIFS()] function? Will you use the same bins for each type, or will each type have its own bins? The bins in the histogram don't seem to match the bins/ranges in the original table (probably my misunderstanding what you wanted to do).

    If you are using the Data analysis histogram tool, I would recommend that you learn how to use the FREQUENCY() function to create the histogram instead of the histogram tool. If you are unfamiliar with the FREQUENCY() function: https://support.office.com/en-us/art...7-fd9ea898fdb9 If I understand better what you want, I would expect a spreadsheet with:
    1) A column of bins (6.56, 14.06, 21.56, 29.06) if they are going to be the same for each type
    2) A FREQUENCY() function for each type =FREQUENCY(relative reference to Type1 column,absolute reference to bins column) -- pay careful attention to the array function nature of the FREQUENCY() function and how to correctly enter it -- select the desired range, enter the function, confirm with ctrl-shift-enter.
    3) Copy the FREQUENCY() function across so that you have a column for each type
    4) Create stacked column chart from the resulting frequency data.

    Am I getting closer to understanding what you want?

  8. #8
    Registered User
    Join Date
    09-22-2016
    Location
    California, USA
    MS-Off Ver
    2016 Excel
    Posts
    7

    Re: Stacked Histogram?

    Thanks for the quick attachment guide.. I think I got it on this post (the native attachment button on the reply tab doesn't seem to link to anything)

    1) Yes, the x-axis should be a column of bins (what I was referring to as ranges - may have been poor terminology on my part). These bins in my example were automatically defined by Excel, but realistically I would user define them depending on what I user defined as reasonable. Every machine "type" should have the exact same bin.

    2) I am not accustomed to Excel functions but do have experience with coding in general. By the sounds of it, FREQUENCY is exactly what I want to show up on my y-axis. Y axis should be FREQUENCY of data points falling within x-axis bin range. I was trying to avoid applying functions just for my own personal ease of use and lack of knowledge surrounding Excel nomenclature.

    3) I'll try that now

    4) I think we're going to figure this out
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    09-22-2016
    Location
    California, USA
    MS-Off Ver
    2016 Excel
    Posts
    7

    Re: Stacked Histogram?

    Hi MrShorty - after playing around with the FREQUENCY function I was able to make the stacked chart that I wanted. I will say though, the inability to edit the array once it is made is a huge pain. Starting from scratch if I want to change the bin size is silly.

    Thanks for all the input. I am going to mark this as resolved and hopefully the person from the other thread will be able to follow what was done.
    example3.JPG

  10. #10
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Stacked Histogram?

    Let us know where you get stuck -- Never mind.

    If you want to get around the array function part, you can either use the COUNTIFS() function for each cell, or nest the FREQUENCY() function inside of an INDEX() function

    Assuming bins are in A33 down
    B33 =COUNTIFS(B$2:B$26,"<"&$A33)
    B34 =COUNTIFS(B$2:B$26,"<"&$A33,B$2:B$26,">="&$A34)
    B35 and down copy of B34
    copy B33:B?? across to column J

    Or B33=INDEX(FREQUENCY(B$2:B$26,$A33:$A??),rows($A$33:$A33)) copied down and across as needed. For someone who is not "comfortable" with spreadsheet formulas, be sure to note how I used a mix of relative and absolute references to make copying easy.
    Last edited by MrShorty; 09-23-2016 at 02:39 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Combining a Column histogram with a stacked column in a single chart
    By Mythicos in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-25-2016, 12:40 PM
  2. Stacked... histogram?
    By mrtaufiq in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 08-22-2013, 07:56 AM
  3. Replies: 1
    Last Post: 05-30-2013, 10:03 AM
  4. Superimposed histogram A on histogram B
    By firuz in forum Excel General
    Replies: 5
    Last Post: 05-26-2007, 09:10 PM
  5. [SOLVED] I was creating a histogram; now i have data but no histogram.
    By ShannonMills3 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-13-2006, 07:10 PM
  6. [SOLVED] How to Histogram w/o raw data but histogram Table on Excel
    By 2005 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-01-2006, 02:50 AM
  7. [SOLVED] To create a stacked column chart and group the stacked bars togeth
    By Jacqueline in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-18-2005, 10:06 AM

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