On Jun 1, 2015, at 5:39 AM, ivo welch wrote: > thank you. yes, I got bitten by "FAQ 7.22: Why do lattice/trellis > graphics not work?" It had never occurred to me that this could be > expected behavior or a FAQ. (didn't show up in a google search for > contourplot.) Unless one knows, this is a puzzler. Thanks for the > pointer. so, a minimum working example is > > require(lattice) > d <- data.frame( expand.grid( x = seq(0,6,length.out=100), y = > seq(0,6,length.out=100) ) ) > d <- within(d, z <- sin( (x+y) )) > xx <- contourplot( z ~ x * y, data = d) > print(xx) ## necessary in source code, but not in interactive mode
I do not think FAQ 7.22 was the problem. Look at the structure of your two different 'd' objects. One of them had the proper long form of an x-y grid with z values while the other one did not. (Also a Mac user but this has nothing to do with Macs.) I was getting a "blank plot" with your first version but getting the expected contours at minus 45 degrees for the second version regardless of any print commands. But my "blank plot had axes that had an appropriate range but was empty inside (no contours) so it wasn't a completely empty plotting event. I don't think `contourplot` was able to make any sense out of the completely irregular data in the first instance. I do agree with Newmiller's second guess that the description of x (i.e.formula) on the help page is the correct reference, but I think you misinterpreted his meaning. -- David. > > regards, /iaw > > > ---- > Ivo Welch (ivo.we...@gmail.com) > http://www.ivo-welch.info/ > J. Fred Weston Professor of Finance > Anderson School at UCLA, C519 > Director, UCLA Anderson Fink Center for Finance and Investments > Free Finance Textbook, http://book.ivo-welch.info/ > Editor, Critical Finance Review, http://www.critical-finance-review.org/ > > > > On Mon, Jun 1, 2015 at 1:29 PM, Jeff Newmiller <jdnew...@dcn.davis.ca.us> > wrote: >> The help for for contourplot answers this question in the description of the >> formula (x) argument. >> --------------------------------------------------------------------------- >> Jeff Newmiller The ..... ..... Go Live... >> DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... >> Live: OO#.. Dead: OO#.. Playing >> Research Engineer (Solar/Batteries O.O#. #.O#. with >> /Software/Embedded Controllers) .OO#. .OO#. rocks...1k >> --------------------------------------------------------------------------- >> Sent from my phone. Please excuse my brevity. >> >> On June 1, 2015 7:02:00 AM EDT, Jeff Newmiller <jdnew...@dcn.davis.ca.us> >> wrote: >>> What does quartz() have to do with this? If quartz is the problem, >>> R-sig-mac would be a better place to ask. Or are you being bitten by R >>> FAQ 7.22? >>> --------------------------------------------------------------------------- >>> Jeff Newmiller The ..... ..... Go >>> Live... >>> DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live >>> Go... >>> Live: OO#.. Dead: OO#.. Playing >>> Research Engineer (Solar/Batteries O.O#. #.O#. with >>> /Software/Embedded Controllers) .OO#. .OO#. >>> rocks...1k >>> --------------------------------------------------------------------------- >>> >>> Sent from my phone. Please excuse my brevity. >>> >>> On June 1, 2015 6:24:18 AM EDT, ivo welch <ivo.we...@gmail.com> wrote: >>>> Dear R (3.2.0, osx) experts: I would like to create contourplots from >>>> irregular data frames (i.e., not a matrix on a grid). I am getting >>>> inconsistent results from lattice contourplot(). sometimes it works >>>> (quartz plot on contours), sometimes it doesn't (blank plot = nada). >>>> I have tried variations from >>>> http://stackoverflow.com/questions/10805093/contour-plot-from-data-frame >>>> , but I do not understand the problem here. contourplot gives no >>>> error messages. >>>> >>>> an example is >>>> >>>> require(lattice) >>>> >>>> d <- data.frame( x = (1:30 + rnorm(30)), y = (1:30 + rnorm(30)) ) >>>> d <- within(d, z <- sin(x+y)) >>>> >>>> quartz() >>>> contourplot( z ~ x * y, data = d) >>>> >>>> am I committing an error, or is there something more robust or at >>>> least verbose, perhaps? >>>> >>>> help appreciated. /iaw >>>> >>>> ---- >>>> Ivo Welch (ivo.we...@gmail.com) >>>> http://www.ivo-welch.info/ >>>> >>>> ______________________________________________ >>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >>>> https://stat.ethz.ch/mailman/listinfo/r-help >>>> PLEASE do read the posting guide >>>> http://www.R-project.org/posting-guide.html >>>> and provide commented, minimal, self-contained, reproducible code. >>> >>> ______________________________________________ >>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >> > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.