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]
st: RE: Problems opening a Stata produced graphics file with any other program afterwards [was: Re: statalist-digest V4 #3966]
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: Problems opening a Stata produced graphics file with any other program afterwards [was: Re: statalist-digest V4 #3966]
Date
Mon, 8 Nov 2010 12:10:40 +0000
Christopher Robert [not Roberts] is the author of -cmogram-, although not named as such in the help file, a rather surprising omission.
What he is explaining here -- and these are my words not his -- is that the -saving()- option of -cmogram- is a non-standard option which in fact calls up -graph export-.
I did not realise this when replying earlier. (I did not read the help for -cmogram-, as I assumed that -saving()- was just a standard -graph- option.) The help for -cmogram- does say
"saving(filename) exports the graph to filename and closes the graph window. This
option is ideal for automating the output of graphs with .do files."
but it might be easy to miss the crucial word "export".
However, in my view, this option naming is not at all good style. I can say firmly that this would, for example, not be consciously allowed if a program like this were submitted to the Stata Journal.
-saving()- has been the option name for saving a graph file in Stata's own graph file format since whenever (since at least Stata 2.0, which is the oldest manual on my shelves). To take that name and give it functionality with different meaning has much potential for confusion.
Irrespective of whether the implementation of Christopher's -saving()- option is buggy,
which may well be the case, I'd recommend strongly that it be renamed, say as -export()-, and that -cmogram- be amended to allow a standard -saving()- option as well.
Nick
[email protected]
Christopher Robert
==================
I think that the problem is the ", replace" in your saving() option.
cmogram (for better or for worse) always replaces, and doesn't take a
replace option. In the code below, it seems the ", replace" may be
passed to graph export in an odd way. I'm surprised that it's not
showing up in the filename.
if "`saving'"~="" {
graph export "`saving'", name(combined) replace
graph drop combined
}
However, I suspect that it's confusing the export command with respect
to the format, so that Nick's right: it's being saved in Stata format
rather than the format you think it's being saved in. I have had good
luck saving as both .png and .eps, and I suspect you will too once you
drop the ", replace" option.
Nick Cox
=========
Specifying .png or .eps in a -saving()- option applies that extension but does not convert them to the file format you think is implied. They remain Stata graphs, but now with misleading extensions. So external programs cannot make head or tail of them.
You need to use -graph export-.
Jen Zhen
========
I am producing some nice graphs with Chris Roberts' cmogram command.
However, after I've saved them, I cannot open or view them.
I've tried both saving them as "graph.png" and as "graph.eps".
I've also tried it both by adding to the graphing command the option
- -- saving("graphname&directory", replace) --,
and by using separately, i.e. afterwards, the command -- graph save
"graphname&directory", replace --.
But I only get files that afterwards I can open neither directly (when
I double-click on it I get the error message "invalid image") nor in
Scientific Workplace/Latex (where I get the error message "current
file data is bad in [graphname&directory]" or "Could not import file
[graphname&directory]".
Does anyone know what's wrong here? Just in case I should maybe add
that before I can look at them I have to file-transfer them out of the
secure data server, but I don't think the transfer program would in
any way damage the files?
I'm also giving you my complete graphing command:
cmogram depvar indepvar if sample==1 & inrange(indepvar,90,110),
scatter cutpoint(100) lineat(100) qfit histopts(bin(10))
title("Title") graphopts(note("notes" "and more notes"))
saving("/directory/graph.png", replace)
*
* 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/