Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.1K Views
|
3 Replies
|
1 Total Like
View groups...
Share
Share this post:

Create strings from plotNames

Posted 5 years ago

Given a list of plots, create names for the plots.

For example, create two plots, place them in a list, thread HoldForm to each item in the list, then use the list to create strings for use by Export. The following works, but isn't useful for my application, would like to use a variable which contains the list of plots.

plot01 = Plot[Sin[x], {x, 0, 6}];
plot02 = Plot[Cos[x], {x, 0, 6}];
plotList = {plot01, plot02};
plotListHold = Thread@HoldForm[{plot01, plot02}]
Export[FileNameJoin[{"C:", "Temp", ToString[#] ~~ ".jpg"}], 
   ReleaseHold[#]] & /@ plotListHold

Some version of the following is what I would like to do. Note that the code attempts to use Map to Apply HoldForm to each item in the variable plotList. The following doesn't work. Have tried various alternatives, but without success.

plot01 = Plot[Sin[x], {x, 0, 6}];
plot02 = Plot[Cos[x], {x, 0, 6}];
plotList = {plot01, plot02};
plotListHold = Map[HoldForm, plotList];
Export[FileNameJoin[{"C:", "Temp", ToString[#] ~~ ".jpg"}], 
   ReleaseHold[#]] & /@ plotListHold

Some discussion on Stack Exchange Suggestions, perhaps for refactoring the approach, and any discussion of the background about what is gong on would be appreciated.

The overall goal is to define a list of all that plots that have been created in a session, then use the Symbol Names for the plots to create strings to be used by when Exporting the plots.

Attachments:
POSTED BY: Robert McHugh
3 Replies

Does this help you?

Am I misunderstanding anything?

Regards

POSTED BY: Neil Singer
Posted 5 years ago

The suggestion you provided was interesting, but is more complicated than I would like. In part, because I would like the notebook to be used and edited by staff with only limited experience with Mathematica. Expect to be exporting lists of up to 100 plots. Want to develop some examples, so that staff can focus on creating plots, feel that they understand what the code is doing, and keep the mechanics of doing that as straight-forward as possible.

For the moment, we are using something like the following, where the HoldForm statement is earlier than in my previous inquiry.

plot01 = Plot[Sin[x], {x, 0, 6}];
plot02 = Plot[Cos[x], {x, 0, 6}];
plotListHold = Thread@HoldForm[ {plot01, plot02}];
Export[FileNameJoin[{"C:", "Temp", ToString[#] ~~ ".jpg"}], 
   ReleaseHold[#]] & /@ plotListHold

Would like to hear more about your warnings about possible pitfalls when using HoldForrm. Apologies for the delayed response.

Attachments:
POSTED BY: Robert McHugh
POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard