开发者

How to draw several graphics in one picture in Mathematica?

开发者 https://www.devze.com 2023-03-19 09:21 出处:网络
Just like hold on in Matlab. I met this pr开发者_JAVA百科oblem when i want to draw several lines in one picture.

Just like hold on in Matlab.

I met this pr开发者_JAVA百科oblem when i want to draw several lines in one picture.

The number of lines varies.


Mathematica has a lot of constructs allowing you to combine plots, graphics and images.
I'll give you several examples. You can search the help system to find out more and understand the subtleties of the examples bellow:

How to draw several graphics in one picture in Mathematica?

Edit

If you want to read/write from/to files, the following code may serve you as a starting guide:

(*Create data*)
data = RandomReal[1, {8, 2}];
(*Put into a file*)
Export["c:\\test.tab", data, "Table"];
(*Read the file into another list*)
rdat = Import["c:\\test.tab", "Table"];
(*And Plot it like before*)
Graphics[{Line@#, Red, PointSize[Large], Point /@ #} &@rdat]

How to draw several graphics in one picture in Mathematica?


Mathematica 8 introduced a new versatile function Overlay, which can be used to graphically overlay any type of expression:

Overlay[{Graphics[{Yellow, Disk[]}], "Sun"}]


Use Show to combine graphics objects.

Show[Plot[Sin[x],{x,0,10}], Plot[Cos[x],{x,0,10}]]

EDIT If you want to draw several lines, then build your Graphics object out of several lines:

Graphics[ Table[ Line[{{0,0}, {Cos[x],Sin[x]}}], {x,0,Pi,Pi/10} ] ]


combine graphics primitives like Szabolcs said:

Graphics[ Table[ Line[{{0,0}, {Cos[x],Sin[x]}}], {x,0,Pi,Pi/10} ] ]

but if you are using plot then what you need to do is:

Show[Table[Plot[A Sin[x],{x,0,2 Pi}],{A,0.1,10}]]

Show command allows you to combine the graphics Table produces varying A, each one of them a Plot over x.

0

精彩评论

暂无评论...
验证码 换一张
取 消