0
$\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
    $\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$ – J. M.'s technical difficulties Nov 30 '19 at 5:56
  • 1
    $\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$ – wuyudi Nov 30 '19 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$ – J. M.'s technical difficulties Nov 30 '19 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.