Advertisement
Guest User

Untitled

a guest
Sep 15th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. p = Plot[Sin[x], {x, 0, 1}]
  2.  
  3. Show[p, (* Option?? *)]
  4.  
  5. p = Plot[Sin[x], {x, 0, 1}]
  6. col = Cases[p, _Hue, Infinity][[1]];
  7. Show[p /. col -> Red]
  8.  
  9. myplot = Plot[{Cos[x], Sin[x]}, {x, 0, 2 Pi},
  10. PlotStyle -> {{Red, Dashing[None]}, {Green, Dashing[None]}}]
  11.  
  12. newstyles = Directive @@@ {
  13. {Green, Thickness[.02], Dashing[Tiny]},
  14. {Thickness[Large], Red}
  15. };
  16.  
  17. i = 1;
  18. MapAt[# /. {__, ln__Line} :> {newstyles[[i++]], ln} &, myplot, {1, 1}]
  19.  
  20. restylePlot[plot_Graphics, styles_List, op : OptionsPattern[Graphics]] :=
  21. Module[{x = styles}, Show[
  22. MapAt[# /. {__, ln__Line} :> {Directive @ Last[x = RotateLeft@x], ln} &, plot, 1],
  23. op
  24. ]]
  25.  
  26. myplot2 = Plot[Evaluate[Table[BesselJ[n, x], {n, 4}]], {x, 0, 10}, Filling -> Axis]
  27.  
  28. restylePlot[myplot2,
  29. {
  30. {Green, Thickness[.02], Dashing[Tiny]},
  31. {Thickness[Large], Red},
  32. Blue
  33. },
  34. Axes -> False,
  35. Frame -> True,
  36. FrameStyle -> Directive[20, FontColor -> Orange]
  37. ]
  38.  
  39. restylePlot2[p_, op : OptionsPattern[Plot]] :=
  40. ListPlot[Cases[Normal@p, Line[x__] :> x, ∞], op, Options[p]]
  41.  
  42. restylePlot2[myplot2,
  43. PlotStyle -> {{Green, Thick, Dashed}, {Thickness[Large], Red}, Blue},
  44. Filling -> Axis, FrameStyle -> Directive[20, FontColor -> Orange],
  45. PlotLegends -> LineLegend[{"1", "2", "3", "4"}]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement