Dear R-Gurus, I am preparing a multiple-plot-sheet with 2rows and 2 columns, but there are actually only 3 plots to plot. the 4. part of my sheet should contain a table with simple statistic values like n, mode, standard deviation.... I cannot handle to plot the information in the plot. the summary() function prints it to the xtrem instead of the plot. Here is an example-plot with the 3 plots and the empty 4.th space. http://frosch.2y.net/tmp/ws_34_geol_20.png Perhaps there is a nice sollution. btw. I produce the plot in BATCH-mode. Thanks so far. steph -- Linux: the operating system with a CLUE... Command Line User Environment. -------------------------------------- Stephan Holl GnuPG Key-ID: 11946A09 ICQ# 117277975 -------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-help/attachments/20020710/6c2bdf76/attachment.bin
> -----Original Message----- > From: owner-r-help at stat.math.ethz.ch[mailto:owner-r-help at stat.math.ethz.ch] On> Behalf Of Stephan Holl > Sent: Wednesday, July 10, 2002 5:19 AM > To: r-help at stat.math.ethz.ch > Subject: [R] plotting only text as a table > > Dear R-Gurus, > > I am preparing a multiple-plot-sheet with 2rows and 2 columns, butthere> are actually only 3 plots to plot. > the 4. part of my sheet should contain a table with simple statistic > values like n, mode, standard deviation.... > > I cannot handle to plot the information in the plot. the summary() > function prints it to the xtrem instead of the plot. > > Here is an example-plot with the 3 plots and the empty 4.th space. > http://frosch.2y.net/tmp/ws_34_geol_20.png > > Perhaps there is a nice sollution. > btw. I produce the plot in BATCH-mode. > Thanks so far. > > stephTwo approaches: 1. Review the math formula table plots that are towards the end of the demo(graphics) programs, which plot a row/column matrix of cells. There are some generic functions in that code to create the table matrix and plot text in the cells. 2. What I recently did was to use the plot() function to create a graphic window with enough horizontal rows (ie. Y-axis range) to contain titles, spaces and the textual data that I wish to display. I also set the window margins fairly narrow [ie. par(mar = c(1, 1, 1, 1) + 0.1) ], so that I could use most of the window for drawing text within the plot area. Using the text() function, I then draw the text at the appropriate row/column positions to create the table with column alignments as I require. If you define the plot vertical range appropriately, you can use integer values of Y for the vertical row centers. Then it is a matter of adjusting the x-axis value to the columns you wish to create and the "cex" parameter in text() to set the text size that looks good for your table. One note, if you wish to create a column of right aligned numbers, where the decimal points are lined up, use the formatC() function to define the number of digits after the decimal place [ie. formatC(Number, digits = 2, format = "f") ]. Then use "pos = 2" in the text() function [ie. text(x, y, Number, pos = 2) ], which will draw the text to the left of a given x-axis reference point. Conversely, if you wish to have generic text that is left aligned, use "pos = 4", which will plot the text to the right of a given x-axis reference point. This took some trial and error for me to get it to work, but it gets the job done. If you want to create lines in your table (ie. cell boundaries, etc), you can use the segments() function for this. As you do with your 3 data plots, be sure to adjust the above so that it works within your 2 x 2 graphic matrix. HTH. Marc -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Marc> Two approaches: > > 1. Review the math formula table plots that are towards the end of the > demo(graphics) programs, which plot a row/column matrix of cells. > There are some generic functions in that code to create the table > matrix and plot text in the cells.as a newbi it is not easy to understand that code, but I try hard. perhaps you can provide some code-snippets for viewing... thanks anyway cheers steph -- Linux: the operating system with a CLUE... Command Line User Environment. -------------------------------------- Stephan Holl GnuPG Key-ID: 11946A09 ICQ# 117277975 -------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-help/attachments/20020710/180afc4f/attachment.bin
On Wed, 10 Jul 2002, Stephan Holl wrote:> Dear R-Gurus, > > I am preparing a multiple-plot-sheet with 2rows and 2 columns, but there > are actually only 3 plots to plot. > the 4. part of my sheet should contain a table with simple statistic > values like n, mode, standard deviation.... > > I cannot handle to plot the information in the plot. the summary() > function prints it to the xtrem instead of the plot. >If you have some lines of text in variable foo you can get a reasonable start on plotting it with plot.new() plot.window(xlim=c(0,1),ylim=c(0,1)) text(0.5,0.5, paste(foo,collapse="\n")) which will put it centered horizontally and vertically. You will probably then need to adjust things. If you want the text to be the output of an R command and can't figure out how to construct the text yourself you can capture it in a textConnection. There is an example in help(textConnection). -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> -----Original Message----- > From: Stephan Holl [mailto:sholl at gmx.net] > Sent: Wednesday, July 10, 2002 9:44 AM > To: MSchwartz at medanalytics.com > Cc: r-help at stat.math.ethz.ch > Subject: Re: [R] plotting only text as a table > > Dear Marc > > > Two approaches: > > > > 1. Review the math formula table plots that are towards the end ofthe> > demo(graphics) programs, which plot a row/column matrix of cells. > > There are some generic functions in that code to create the table > > matrix and plot text in the cells. > as a newbi it is not easy to understand that code, but I try hard. > perhaps you can provide some code-snippets for viewing... > > thanks anyway > > cheers > stephLet me give you an example using my second option. This will generate a text table with a centered title and two columns below. One column with left aligned text and one column with right aligned numbers. # This preserves current graphic parameters # for restoration at the end old.par <- par(no.readonly = TRUE) # This sets the plot region margins to be thin par(mar = c(1, 1, 1, 1) + 0.1) # this sets up the empty plot window # with x-axis range as 0 to 4 and # the y-axis range as 0 to 6 # with no labels and no plot frame plot(0, 0, xlim = c(0, 4), ylim = c(0, 6), type = "n", axes = FALSE, ann = FALSE, frame.plot = FALSE) # Set a vector of text for the left aligned column Col1 <- c("This is Row 1", "This is Row 2...", "This is Row 3.....") # Set a vector of numbers for the right aligned column # First set up some real numbers, then format them with # only one decimal place each using formatC() Col2 <- c(4, 5.3785, 6.345) Num <- formatC(Col2, digits = 1, format = "f") # Now plot the text on the graphic window # First plot text for a centered title, with large text (cex = 2.0) text(2, 5, labels = "This is a centered title", cex = 2.0) # Finally, plot the number column as right aligned. # Note the use of pos = 4 # Use y-axis values of 4, 3, 2 # with a x-axis value of 1 text(1, c(4, 3, 2), labels = Col1, pos = 4, cex = 1.0) # Finally, plot the number column as right aligned. # Note the use of pos = 2 # Use y-axis values of 4, 3, 2 # with a x-axis value of 3 text(3, c(4, 3, 2), labels = Num, pos = 2, cex = 1.0) # Restore Graphic Parameters par(old.par) If you need other examples or formatting help, let me know. Keep in mind that in my example, the y-axis runs from bottom to the top with increasing numbers (0 to 6). Note that the text() function y-axis coordinate values decline as the actual row number text values (Row 1, Row 2, Row 3) that I used increase. Regards, Marc -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Marc, <snip> Thank you for your detailed information about this topic. Now I see clearer and mostly understand how to plot text! cheers steph -- Linux: the operating system with a CLUE... Command Line User Environment. -------------------------------------- Stephan Holl GnuPG Key-ID: 11946A09 ICQ# 117277975 -------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-help/attachments/20020710/1fb2da0c/attachment.bin