1

I want to get the line from plot. Then I use

Plot[Sin[x], {x, 0, 1}, MaxRecursion -> 1][[1, 1, 1, 3]]

I get somthing. But when I use

Plot[Sin[x], {x, 0, 1}, MaxRecursion -> 1][[1, 1, 1, 3, 2]]

I get

"Charting`Private`Tag$33789#1"

And I find the solution from here.

https://mathematica.stackexchange.com/a/114775

My question is : why can't that work?

AsukaMinato
  • 9,758
  • 1
  • 14
  • 40
  • 3
    That solution using [[1, 1, 1, 3]] is really not recommended, because the details of how the Graphics[] primitives are embedded can differ between versions of Mathematica. Try Cases[Normal[Plot[Sin[x], {x, 0, 1}, MaxRecursion -> 1]], _Line, Infinity] instead. – J. M.'s missing motivation Nov 30 '19 at 05:56
  • 2
    ok,thanks. I use pl = Plot[Sin[x], {x, 0, 1}, MaxRecursion -> 1]; Graphics@Line@Cases[pl, Line[pts_] :> pts, Infinity] to solve it. – AsukaMinato Nov 30 '19 at 06:09
  • 1
    Your proposal removes the Line[] head only to add it back in later. Don't you think this is a little wasteful? – J. M.'s missing motivation Nov 30 '19 at 06:13

0 Answers0