Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: graph combine of tabplot graphs: uncomparable bar heights |

Date |
Fri, 28 Jun 2013 12:22:24 +0100 |

-tabplot- is from SSC. You are asked to explain where user-written programs you use come from. Otherwise you waste the time of anyone who thinks "That sounds interesting" but then can't find -tabplot- on their system because it has not been installed. The small point of giving credit to whoever wrote it I leave on one side. This is all explained in the FAQ you were asked to read before posting. The underlying problem is that -tabplot- internally uses a scale that is only indirectly unrelated to the numbers being shown. In a case like sysuse auto tabplot foreign rep78 , showval the highest bar is drawn between y = 2 and y = 2.8. If the highest bar had been on the bottom row it would have been drawn between y = 1 and y = 1.8. This is regardless of what the highest bar represents. -graph combine- can only align x and y coordinates; it won't restructure the graphs internally. Similarly -yscale()- can have no effect here, because scaling has already taken place. In fact it could not be otherwise. Much of the effort of -tabplot- goes into using the space available as effectively as possible. The default is to leave 20% vertical space between the height of the tallest bar and the line above (or correspondingly if the bars are aligned horizontally). You have I think two choices. One is to choose a -height()- option separately for each graph so that the values come out as you want when you combine them. The second is to restructure your data, so that you use a -by()- option as well with -tabplot-. Then the bars in each panel will be drawn on the same scale. Nick njcoxstata@gmail.com On 28 June 2013 11:34, Brunelli Cinzia <Cinzia.Brunelli@istitutotumori.mi.it> [edited] > I'm going to combine together in a single figure 3 graphs previously obtained with -tabplot- to show patients and physician agreement on the assessment of three different variables. > > The syntax is the following > > tabplot ecs_cp_q2 alberta_q0_imput, showval percent xtitle(" " " ") subtitle ("") /// > ytitle("PHYSICIAN ASSESSMENT") title("INCIDENT PAIN", size(msmall)) saving(IP_AGREE, replace) > tabplot ecscp_neu pain_dtct_cat2, showval percent xtitle(" " "PATIENT ASSESSMENT") subtitle ("") /// > ytitle("") saving(NP_AGREE, replace) title("NEUROPATHIC PAIN ", size(msmall)) yscale(range(0 1)) > tabplot ecs_cp_q3 any_dep_PHQ, showval percent xtitle(" " " ") subtitle ("") /// > ytitle("") saving(PD_AGREE, replace) title("PSYCHOLOGICAL DISTRESS", size(msmall)) > > graph combine IP_AGREE.gph NP_AGREE.gph PD_AGREE.gph, col(3) ycommon xcommon > > The commands work and the figure is nice but... proportions between bar heights are correct within each graph but not between graphs: i.e the fourth bar in the first graph, which represents 35% of the sample, is as tall as the first one in the second graph, which should represent 66% of the sample. I guess this has to do with different graphical formatting rules within each graph. > > Is there a way to overcome this misrepresentation? I tried to use something like yscale(range(0 100)) in order to standardize yaxis scale, but it doesn't work. I find -tabplot- very useful for my proposal and it would be a pity not to be able to use it and present a "boring" table. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: graph combine of tabplot graphs: uncomparable bar heights***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**st: graph combine of tabplot graphs: uncomparable bar heights***From:*Brunelli Cinzia <Cinzia.Brunelli@istitutotumori.mi.it>

- Prev by Date:
**st: graph combine of tabplot graphs: uncomparable bar heights** - Next by Date:
**Re: st: table formatting in stata** - Previous by thread:
**st: graph combine of tabplot graphs: uncomparable bar heights** - Next by thread:
**Re: st: graph combine of tabplot graphs: uncomparable bar heights** - Index(es):