- 积分
- 12
- 注册时间
- 2009-2-23
- 仿真币
-
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2011-4-30 03:00:04
|
显示全部楼层
来自 LAN
本帖最后由 guocong89 于 2011-4-30 03:50 编辑
至此,我们基本了解Plot结果的大致结构了,Plot可以看作是一种特殊的Graphics求值器,现根据函数式求出散点序列,转换为Line对象,然后填充到一个Graphics对象里。Plot的那些Axes,Epilog,PlotRange属性,其实是来自于Graphics而已。如果想要把Plot和Circle放到一起,就不能够想当然的把Plot放到Graphics里面了,因为Graphics是不支持嵌套的,可行方法有以下几种- Plot[Sin[x], {x, -1, 1}, Epilog -> Circle[{0, 0}, 0.1]]
复制代码- Show[Plot[Sin[x], {x, -1, 1}], Graphics[Circle[{0, 0}, 0.1]]]
复制代码- Graphics[{Circle[{0, 0}, 0.1],
- Inset[Plot[Sin[x], {x, -1, 1}], {0, 0}, {0, 0}, {1, 1}]}]
复制代码 那么我们如果只想操纵图线而不管坐标轴呢?根据最早的那张图片,不难得出以下的提取步骤- Plot[Sin[x], {x, 0, 4 \[Pi]}] // First // First // Last // Last
复制代码 或者- Plot[Sin[x], {x, 0, 4 \[Pi]}] // Cases[#, Line[___], Infinity] &
复制代码 回到我们最早的那个问题,现在可以就很容易的解决掉了- a = Plot[Sin[x], {x, -4 \[Pi], 4 \[Pi]}] // Cases[#, Line[___], Infinity] &;Graphics[{Blue, Thick, Rotate[a, 90 Degree, {0, 0}]}, Axes -> True, Ticks -> {{-\[Pi], \[Pi]}, Range[-4 \[Pi], 4 \[Pi], \[Pi]]}, PlotRange -> {{-\[Pi], \[Pi]}, Automatic}]
复制代码 |
|