Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to make a series of changes in the appearance of the Plot of some function. I am trying to use Manipulate for my experiments. I tried to change the following code

Manipulate[ Plot[Sin[x], {x, 0, Pi}], {p, HoldForm /@ Options[Plot]}, {q, InputField}]

so that when, for example, p is AxesOrigin ->Automatic and q is changed to {-3,5} then the plot will be updated with Axes Origin at {-3,5}. Similar if p is taken AxesLabeL->None and p is changed to "A label" then the last plot will refreshed showing the label "A label" at the top(without affecting any changes already made in other options like AxesOrigin above).

share|improve this question
    
maybe this can get you started? Manipulate[With[{p1=p[[1,1]]},Plot[Sin[x],{x,0,Pi},p1-> q]], {{p,{PlotLabel-> None}, "Options"},Thread[{Options[Plot]}]},{{q,Null,"Value"},InputField}] –  chuy Nov 5 '13 at 19:16

4 Answers 4

Here's way along the lines in the OP:

Manipulate[
 With[{opts = Sequence @@ opts},
  Plot[Sin[x], {x, 0, Pi}, opts]], {p, 
  PopupMenu[Dynamic[p, (q = opts[[#, -1]]; p = #) &],
    Thread[Range@Length@# -> #] &[First /@ Options[Plot]]] &},
 {{q, Null},
  InputField[
    Dynamic[q, (opts = ReplacePart[opts, {p, -1} -> #]; q = #) &]] &},
 {opts, None},
 TrackedSymbols :> {opts}, Initialization :> (opts = Options[Plot])

Mathematica graphics

share|improve this answer

Here's a different take on how to present the options, using SlideView rather than drop down, which is pretty nice.

I'm sorry for the fast animation, I had to drop a lot of frames to make its size decent.

{names, symbols, values} = 
  Transpose[Options[Plot] /. (Rule[x_, y_] | RuleDelayed[x_, y_]) :> {x, Unique[x], y}];
tables = 
   Partition[MapThread[Function[{name, symbol}, {
      Pane[name, 150], 
      InputField[Dynamic[symbol]]
   }], {names, symbols}], 10];
MapThread[Set, {symbols, values}];
Panel[
 Column[{
   Dynamic@
    Panel[Pane[
      Plot[Sin[x], {x, 0, 2 Pi}, 
       Evaluate[MapThread[Rule[#, #2] &, {names, symbols}]]], 
      BaseStyle -> {Background -> White}]],
   SlideView[
    TableForm /@ tables
    ]
   }]
 ]

animation

share|improve this answer
    
gifsicle -O3 --colors 256 original.gif > smaller.gif brings it down from 1.8M to 784K –  ssch Nov 7 '13 at 22:59
    
@ssch Nice, I'll remember that. Exported it from MMA this time. –  Pickett Nov 8 '13 at 7:11

I don't know if the following code will satisfies you. Of course one could change the code to add more controls like changing 0 and 2Pi corners e.t.c.

f[p_, pt : {___}] := Plot[p[x], {x, 0, 2 Pi}, pt]

 Manipulate[
 If[q =!= Null, PrependTo[r, p[[1, 1]] -> q]]; {p[[1, 1]] -> q, 
  f[Sin, r]}, {p, HoldForm /@ Options[Plot]}, {q, 
  InputField}, {{r, {Axes -> True}}, None}, TrackedSymbols -> {q}]

or similarly,

  Manipulate[If[q =!= Null, PrependTo[r, p[[1, 1]] -> q]]; 
 r = DeleteDuplicates[r, #1[[1]] == #2[[1]] &]; 
 Column@{r, p[[1, 1]] -> q, f[Sin, r]}, {p, 
  HoldForm /@ Options[Plot]}, {q, InputField}, {{r, {Axes -> True}}, 
  None}, TrackedSymbols -> {q}]
share|improve this answer
    
much much better than mine! –  chuy Nov 5 '13 at 20:37

Disclaimer -> this is quick and dirty (emphasis on dirty) first attempt:

Manipulate[
 plot[Sin[x],{x,0,Pi},Sequence@@{s,p[[1,1]]-> q}],
 {{p,{PlotLabel-> None}, "Options"},
 Thread[{Options[Plot]}]},
 {{q,Null, "Value"},InputField}, 
 {{s,{}},Block[{s2},Button["Save State", s2=Append[s,p[[1,1]]-> q];DeleteDuplicates[s2];s=s2]]&}, 
 Initialization:> 
  {plot[func_,{x_,xmin_,xmax_},opts:OptionsPattern[]]:= Plot[func,{x,xmin,xmax}, opts]}]

This (as badly written) has the limitations that you can pink box it with bad values for options. In order to "save a state" hit the button. Further changes should respect these previous ones.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.