1
$\begingroup$

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?

$\endgroup$
3
  • 3
    $\begingroup$ 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. $\endgroup$ Commented Nov 30, 2019 at 5:56
  • 2
    $\begingroup$ ok,thanks. I use pl = Plot[Sin[x], {x, 0, 1}, MaxRecursion -> 1]; Graphics@Line@Cases[pl, Line[pts_] :> pts, Infinity] to solve it. $\endgroup$ Commented Nov 30, 2019 at 6:09
  • 1
    $\begingroup$ Your proposal removes the Line[] head only to add it back in later. Don't you think this is a little wasteful? $\endgroup$ Commented Nov 30, 2019 at 6:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.