Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Overlaying a line on a bar chart

    Hello.

    I would like to overlay a line on a bar chart (with multiple bars) which was created with graph bar. Is this possible?

  • #2
    Hello Belinda,

    Try the option -yline()-.
    Code:
    help added_line_options
    Keep in mind, for -graph bar-, yline is the only added line option, since there is no numeric x-axis to put an xline onto. If you want to add vertical lines, I would suggest reformatting your data and using -twoway-.

    Comment


    • #3
      Roger thanks but this is not what i want. I would like to add a line on the y-axis which fluctuates depending on each category on the x-axis.

      Comment


      • #4
        I think you need to move to twoway bar to do that. Give example data, and example code will likely follow.

        Comment


        • #5
          Nick, basically I have a bar chart created with graph bar, in which there are a number of bars each indicating the counts of a bin. I would like to plot in the same graph the normal distribution for the entire range (from first to last bar). Is this possible with graph bar?

          This has been done in MATLAB before, see here: https://www.mathworks.com/matlabcent....mathworks.com

          Comment


          • #6
            This question keeps morphing...

            graph bar and normal. Not that I know of. The whole conceit of graph bar is that it is for categories. Whether you think of the categories as being on a numerical scale is up to you and no concern of graph bar.

            I have used MATLAB on occasion but not for some time, and I am too lazy to find a machine to run that code. But assuming that the word description is enough, the easy way to superimpose a histogram (rather than bar chart) with a normal distribution is to use histogram

            Code:
            sysuse auto, clear 
            histogram mpg, normal

            Comment

            Working...
            X