Announcement

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

  • Histogram : How to obtain a nice distribution plot with widely scattered values?

    Hi,

    I would like to obtain a nice histogram, or density plot about the distribution of two variables that are widely scattered in one and unique plot. These two variables contain a lot of repetitive values.
    Here is an example of the dataset. The variable count_power_p1 is basically the count for each value appearing in power_p1:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long(power_p1 power_p2) float count_power_p1
    0     0  9
    0  4000  9
    0  4000  9
    0     0  9
    0     0  9
    0     .  9
    0     .  9
    0  4000  9
    0     0  9
    1 18000 37
    1 18000 37
    1  5196 37
    1 12000 37
    1 17000 37
    1 17000 37
    1     1 37
    1  2300 37
    1 12000 37
    1  2300 37
    1  5196 37
    1 18000 37
    1 18000 37
    1  5196 37
    1 18000 37
    1     1 37
    1 12000 37
    1 12000 37
    1     1 37
    1  2300 37
    1 17000 37
    1 18000 37
    1     1 37
    1  5196 37
    1  4000 37
    1     1 37
    1 12000 37
    1  2300 37
    1 17000 37
    1 15001 37
    1  5196 37
    1  2300 37
    1  2300 37
    1 18000 37
    1  5196 37
    1 17000 37
    1 20000 37
    2     2  1
    3     5  7
    3     3  7
    3     3  7
    3     3  7
    3     3  7
    3     3  7
    3     3  7
    4     4  7
    4     4  7
    4     4  7
    4     4  7
    4     4  7
    4     4  7
    end

    Could anyone help me please?
    Here is the graph that I obtain, which is not what I wanted:
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	56.5 KB
ID:	1727653



    That was the used code:

    Code:
    hist count_power_p1
    (bin=61, start=0, width=4458.1311)
    Best,

    Michael
    Last edited by Michael Duarte Goncalves; 20 Sep 2023, 02:02.

  • #2
    The discreteness is part of that variable, and your graph must represent it. For such situations I like spikeplot.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Hi Maarten Buis,

      Thank you very much for your help.
      I will have a look on -spikeplot-.

      All the best,

      Michael

      Comment

      Working...
      X