Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

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

From |
Brunelli Cinzia <Cinzia.Brunelli@istitutotumori.mi.it> |

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

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

Date |
Fri, 28 Jun 2013 15:30:09 +0200 |

Dear Nick, thank you very much for your helpful suggestions and clear explanation: now the bars have their correct height! Best wishes Cinzia P.S. I'm sorry not to have cited the source of -tabplot-, but I had missed that indications before joining statalist. -----Messaggio originale----- Da: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Nick Cox Inviato: venerdì 28 giugno 2013 14.40 A: statalist@hsphsun2.harvard.edu Oggetto: Re: st: graph combine of tabplot graphs: uncomparable bar heights Here's a dopey example to show the principle. By comparing the initial graphs, we see that the highest bar on both graphs shows 30. So the scale for the other graph (highest bar 27) must be adjusted relative to that. Note that the height to be used can be worked out by Stata on the fly: `=0.8 * 27/30' says "work out the result of 0.8 * 27/30 and use it". sysuse auto, clear tabplot foreign rep78 , showval gen himpg = mpg > 30 label define himpg 1 ">30" 0 "<= 30" label val himpg himpg label var himpg "miles per gallon >30?" tabplot himpg rep78 , showval tabplot foreign rep78 , showval height(`=0.8 * 27/30') name(g1) tabplot himpg rep78 , showval name(g2) graph combine g1 g2, ycommon Nick njcoxstata@gmail.com On 28 June 2013 12:22, Nick Cox <njcoxstata@gmail.com> wrote: > -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/ La presente comunicazione, che potrebbe contenere informazioni riservate e/o protette da segreto professionale, è indirizzata esclusivamente ai destinatari della medesima qui indicati. Ogni informazione qui contenuta, che non sia relativa alla nostra attività caratteristica, deve essere considerata come non inviata. Nel caso in cui abbiate ricevuto per errore la presente comunicazione, vogliate cortesemente darcene immediata notizia, rispondendo a questo stesso indirizzo di e-mail, e poi procedere alla cancellazione di questo messaggio dal Vostro sistema. E' strettamente proibito e potrebbe essere fonte di violazione di legge qualsiasi uso, comunicazione, copia o diffusione dei contenuti di questa comunicazione da parte di chi la abbia ricevuta per errore o in violazione degli scopi della presente. Ricordiamo che la tecnologia di trasmissione utilizzata non consente di garantire l’autenticità del mittente né l’integrità dei dati This communication, which may contain confidential and/or legally privileged information, is intended solely for the use of the intended addressees. All information or advice contained in this communication is subject to the terms and conditions provided by the agreement governing each particular client engagement. If you have received this communication in error, please notify us immediately by responding to this email; then please delete it from your system. Any use, disclosure, copying or distribution of the contents of this communication by a not-intended recipient or in violation of the purposes of this communication is strictly prohibited and may be unlawful. The transmission technology used to send this mail can grant neither the sender identity nor the data integrity * * 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/

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

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

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

- Prev by Date:
**Re: st: drop observations within groups under certain conditions** - Next by Date:
**Re: st: drop observations within groups under certain conditions** - Previous by thread:
**Re: st: graph combine of tabplot graphs: uncomparable bar heights** - Next by thread:
**st: drop observations within groups under certain conditions** - Index(es):