Re: Casting a Command as a String
- To: mathgroup at smc.vnet.net
- Subject: [mg58952] Re: Casting a Command as a String
- From: Peter Pein <petsie at dordos.net>
- Date: Mon, 25 Jul 2005 01:12:08 -0400 (EDT)
- References: <dbv9og$efo$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Bruce Colletti schrieb:
> I have a list of (Combinatorica) graphs (e.g., X = {Cycle@4,CompleteGraph@3}), and want to automatically display each with the command as the display title.
>
> For instance, manually working the above list:
>
> ShowGraph[Cycle@4, PlotLabel->?Cycle@4?];
> ShowGraph[CompleteGraph@3,PlotLabel->?CompleteGraph@3?];
>
> How do I automate this for an arbitrary list of (Combinatorica) graphs? Although Scan[ShowGraph,X] displays the titleless graphs, I can?t figure out how to cast a command as a string (so that it can become a title).
>
> Thanks.
>
> Bruce
>
Hi Bruce,
to avoid automatic evaluation of the elements of X, they should be
strings or of type HoldForm[]:
X = {"Cycle @ 4", "CompleteGraph @ 5"};
ShowGraph[ToExpression[#],
PlotLabel -> StyleForm[#, FontSize -> 16]]& /@ X;
will show you the desired result.
--
Peter Pein
Berlin