Bookmark and Share

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]

Re: st: incorporate table into figure


From   Michael McCulloch <[email protected]>
To   [email protected]
Subject   Re: st: incorporate table into figure
Date   Mon, 23 Aug 2010 21:38:12 -0700

Jeph, additionally, the HR+CI data can be easily superimposed above the .tif which you've imported into MS-WORD by using a text box with no borders.
Michael

On Aug 23, 2010, at 9:33 PM, Michael McCulloch wrote:

Jeph,
I've wrestled with this as well, and found it far more efficient and reliable to:
1. Create the .gph and export to .tif with a command such as:
	graph export "my_fig.tif", replace
2. In MS-Word, create a table with four rows and five columns.
3. Merge the 2nd through 5th columns of the top row, and import the .tif file to that newly created large cell. 4. Place the data row labels into the left column of the lower 3 rows, and the data to the right. 5. All cell borders can be set to blank within the Table/Table/ Borders and Shading settings.

Fine-tuning the alignment of data columns is straightforward and quick. By creating the .tif file with Stata, you're assured of high- quality publication-ready graphics.
Michael



On Aug 23, 2010, at 8:14 PM, Eric Booth wrote:

<>

Jeph:
Here are two examples to get you started, though, it might be easier to just place an exported .gph or .eps version of the figure above the formatted table in a Word document and use an image capture software or export the page as an image/pdf.

You can tweak the positioning of the text under a figure or written to a file, but it will take some patience. The code below requires you to install the rtfutil suite of adofiles from Roger Newson (findit rtfutil)

**************!

*! watch for wrapping issues in the code below !*

//setup//
clear all
sysuse cancer
recode _t (30/max = 30)
stset studytime, fail(died)
streg, distribution(exponential)
predict S, surv

//example 1:  text() option//
sts graph, plot(line S _t, sort) legend(pos(4) ring(0) rows(2)) ///
graphregion(margin(vlarge) fcolor(white)) ///
xscale(range(-1 30))   aspectratio(.5, place(12)) text(-.2 -3 ///
"No. at risk"    ///
"  Usual Care	 	 1172		 6811		 1119		  1213			  1212" ///
"  Exercise Train		1444		4242		1233		1231			1213" ///
, place(se) just(left) margin(l+1 t+1 b+1) width(85)) name(test, replace)
graph save test "graph", replace
graph export graph.eps,  as(eps) replace

//exmaple 2: rtfutil / file write//
sts graph, plot(line S _t, sort) legend(pos(4) ring(0) rows(2)) ///
graphregion(margin(vsmall) fcolor(white))  name(test2, replace)
graph save test2 "graph2", replace
graph export graph2.eps,  as(eps) replace
cap rtfclose handle1
tempname handle1
rtfopen `handle1' using "mydoc1.rtf", template(fnmono1) replace
file write `handle1' "{\pard\b JAMA Graph\par}" _n
rtflink `handle1' using "graph2.eps"
file write `handle1' "{\line}"     _n(2)
file write `handle1' "{No. at risk 	 }"  _n
file write `handle1' "{\line}"     _n
file write `handle1' "{ Usual Care 1172 6811 1119 1213 1212}" _n file write `handle1' "{ Exercise Train 1444 4242 1233 1231 1213}" _n
rtfclose `handle1'
**note: this lines up for me using MS Word 2008 on Mac, but may not line up on other configurations**
**************!

~ Eric

On Aug 23, 2010, at 8:44 PM, Jeph Herrin wrote:

I would like to incorporate a very simply (4x2) table into
a figure. I would like the 4 columns to line up with the four
ticks on the x-axis, but appearing below the axis. The row
labels thus need to be in the left margin. In particular, I need
to reproduce a figure such as one of these

http://jama.ama-assn.org/cgi/content/full/301/14/1439/JOC90023F2

and the issue is lining up the numbers across the bottom.

I have tried to set it up as a -caption()- with two strings,
but have two problems. First, I cannot persuade the caption to be
aligned with the left side of the graph; -span- only aligns with the
left edge of the y-axis lable, whereas I have set the margin to be
extra wide with -graphreg(m())-. Second, there seems to be no way
other than experiment to align the 4 columns with 4 ticks on the
x-axis. In the graph editor there is a "position offset" for the
caption box which I can set to <0 to achieve what I want, but
I cannot find any corresponding textbox_option.

Jeph

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


Best wishes,

Michael McCulloch, LAc MPH PhD
Pine Street Foundation
124 Pine Street
San Anselmo, CA 94960-2674
tel:	415-407-1357
fax: 	206-338-2391

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


Best wishes,

Michael McCulloch, LAc MPH PhD
Pine Street Foundation
124 Pine Street
San Anselmo, CA 94960-2674
tel:	415-407-1357
fax: 	206-338-2391

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index