Search code examples
histogramstataaxis-labelsx-axis

Add a "Plus Sign (+)" to a histogram axis using truncated data


I have some data with a long tail, which has been truncated for a histogram. I would like to add a simple "+" sign to the final value of the x-axis on the histogram. Below is an example showing the setup.

sysuse auto
gen price_graph = price
replace price_graph =10000 if price_graph>10000
hist price_graph, start(0) width(1000)

Below is the result of the above code, with the "+" sign drawn in and highlighted where I would like to put it: enter image description here

I could also see scenarios when data would be truncated from the left as well, so a robust solution would be easily applicable to both scenarios.


Solution

  • hist price_graph, start(0) width(1000) xla(0(2000)8000 10000 "10000+") 
    

    You spell out that you want specific text as a specific axis label. You then (optionally) indicate what other labels you want.