Re: Table as Graphics Object?

*To*: mathgroup at smc.vnet.net*Subject*: [mg35066] Re: [mg35027] Table as Graphics Object?*From*: Andrzej Kozlowski <andrzej at platon.c.u-tokyo.ac.jp>*Date*: Thu, 20 Jun 2002 23:55:53 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

I just realized that there is another approach to producing a nice graphic object representing a table or even a matrix. You need to pay attention to the FormatType option in the Text primitive. Here is another version of the graphic below, thsi time we will represent out table as a matrix wiht the usual matrix brackets. In[1]:= ls=Table[Random[Integer,{1,6}],{5},{5}]; In[2]:= myTable=Graphics[Text[ls,{0,0},FormatType->TraditionalForm]]; In[3]:= myGraphic=ListPlot3D[ls,DisplayFunction->Identity]; In[4]:= Show[GraphicsArray[{myGraphic,myTable}]] There are lots of variations onthsi theme you can try and you can of course make, if you wish, use of the options available in Text. Andrzej On Friday, June 21, 2002, at 10:17 AM, Andrzej Kozlowski wrote: > The method that I described produces only a bitmap graphic so I do not > think it will scale well and look good at different image sizes, > besides having the other disadvantages. If you really want something > that works better, and judging by your message you do, you should make > use of the Text primitive. It need not be so hard. Here is one simple > example: > > First we make a table of random number, say between 1 and 6: > > ls = Table[Random[Integer, {1, 6}], {5}, {5}]; > > Next, we make a graphic "version" of the table. Note that there is no > need to bother about the choice of text coordinates for such a simple > example: > > myTable = GraphicsArray[Map[Graphics[Text[#, {0, 0}]] &, ls, {2}]]; > > Let's also make a 3D graphic using list plot and our matrix of values > ls,: > > myGraphic = ListPlot3D[ls, DisplayFunction -> Identity]; > > Now we can display them side by side: > > Show[GraphicsArray[{myGraphic, myTable}]] > > This looks fine, will scale properly and can be automated to deal with > a large number of different cases. Probably a variant of this approach > will also work in your case. > > Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ > > > > On Friday, June 21, 2002, at 03:10 AM, AES wrote: > >> Thank you, and this is wonderful! -- as a way of demonstrating the >> kinds of complex things one can get led into with computers and >> graphics, anyway. I have all those tools, and may try this if I ever >> need to put a table or something similar into a presentation graphic. >> >> What I'm currently doing, however, is running a program that takes in >> a bunch of parameters and calculates a plot, and I want to run a lot >> of cases and produce a single output for each that will include both >> the plot and the long list of parameters that produced the plot. What >> I'm doing currently is >> >> --Print a page break >> --Print a table of paramters >> --Print the plot (size of plot varies) >> --Repeat >> >> The object was to make this a little simpler, and maybe get two cases >> per page, without more complex programming. >> >> So, seriously, I do appreciate your writing, but I don't clearly want >> to follow all your steps 50 or 60 times! >> >> I'd be curious: If you Show your "TableGraphic" several times at >> different ImageSizes, do the fonts and characters scale neatly and >> look good at different sizes? >> >> Thanks again, Tony Siegman >> >> >> >> At 12:35 AM +0900 6/21/02, Andrzej Kozlowski wrote: >> >> >>> There is a trick you may wish to try. I just did it and it seems to >>> work. You will need, besides Mathematica, a graphic program. There >>> might be a clever trick that will make it possible to accomplish the >>> same thing without one, but I have not found it. >>> >>> Anyway, this is what I just did under Mac OS X. >>> >>> First, I created a table with: >>> >>> Table[Random[Integer], {5}, {5}] // TableForm >>> >>> I then selected the output and using the Cell/ConvertTo menu >>> converted it to PICT, a Macintosh graphic format. (I expect other >>> formats will also work). I then copied the graphic and pasted it into >>> GraphicConverter, a well known Mac graphic program (any other such >>> program will do). I then copied the graphic from GraphicConverted and >>> pasted it back into Mathematica. I selected the entire cell and >>> chose ConvertTo InputForm. You get a rather long expression which >>> describes a graphic object (a RasterArray). Evaluate thsi cell, then >>> evaluate myTable= %, and then Show[GraphicsArray[{myTable,myPlot}]] >>> will give you just what you wanted. >>> This does not seem to work without using an external graphic program. >>> Merely converting the Table first to a graphic and then into >>> InputForm produces merely Mathematica input cell, not the input cell >>> for a graphic object. It seems you have to force Mathematica to >>> forget that your graphic was created by converting a Mathematica >>> output cell. >>> >>> Of course this gives you a raster graphic, which is not of the >>> highest quality and rather large. If you want something better you >>> really need to use the Text primitive. >>> > >>> >>> On Thursday, June 20, 2002, at 03:13 PM, aes wrote: >>> >>>> I'd like to include a Table as one of the objects in a >>>> GraphicsArray, using a simple syntax like >>>> >>>> myTable = Table[---] // TableForm >>>> >>>> myPlot = Plot[---] >>>> >>>> Show[ GraphicsArray[ {{myTable, myPlot}} ] >>>> >>>> I know I could built a "psuedo Table" into a Graphics object using >>>> the usual Text[---] commands, but at the cost of a lot of work to >>>> input and position the various lines. >>>> >>>> Any other approaches? >>>> >>>> Thanks, AES >> >