# how to export a manually graph from mathematica

I draw Cos function using the code line :

GraphicsColumn[
{
Plot[Cos[0.0625*Pi x], {x, 0, 40*Pi}, Axes -> False],
Plot[Cos[0.0625*Pi x], {x, 0, 40*Pi}, Axes -> False],
Plot[Cos[0.0625*Pi x], {x, 0, 40*Pi}, Axes -> False],
Plot[Cos[0.0625*Pi x], {x, 0, 40*Pi}, Axes -> False]
}
,ImageSize -> Large
]


and manually add circles and arrows as you can see in the attached picture , how can I export the figure . export doesn't work and I can't save it or copy it please help

• I don't know how to edit from Word, but if I add arrows to a sine plot using the drawing tools and then export the graphic, it seems to work fine. See here – user1066 Jul 30 '18 at 18:27

I know this post could be shorter, but I wanted to outline a methodology, as in teach a man to fish..., so please bear with me. The first point to make is that the geometric scale of x vs y is easiest to manage from within the Graphics[] environment. Each Plot[] command creates its own coordinate context and so you can introduce distortions you don't intend unless you apply a great deal of care. Secondly, mixing different graphical elements is easiest to do in Graphics[] as well.

First of all, decide how to draw the 4 cosine curves. I noticed that your diagrams simply have 4 cycles and no axes so I dispensed with the frequency and duration you used. Here we have a quick set of 4 cosines in a column:

With[{baseline = -2.5 {0, 1, 2, 3}, t = Range[-2, 2, 0.01]},
Module[{s},
s = Cos[2 Pi t];
Graphics[{
Table[Line@Thread@{t, s + baseline[[k]]}, {k, 1, 4}]
}]
]
]


Notice I separated the curves by a little more than their peak to peak height.

Now we want to draw the dots in a systematic way. Imagine each set of dots is drawn with respect to a point on the baseline associated with the cosine curve. We can use the baseline index to also choose that time position.

With[{baseline = -2.5 {0, 1, 2, 3}, t = Range[-2, 2, 0.01], tdots = {-1.5, -0.5, 0.5, 1.5}},
Module[{s, dots},
s = Cos[2 \[Pi] t];
dots[k_] := With[{td = tdots[[k]], y0 = baseline[[k]] + 0.15, dy = 0.4, r = 0.16},
{Red, Disk[{td, y0 + dy}, r], Disk[{td, y0}, r], Disk[{td, y0 - dy}, r]}
];
Graphics[{
Table[Line@Thread@{t, s + baseline[[k]]}, {k, 1, 4}],
Table[dots[k], {k, 1, 4}]
}]
]
]


Now let's add the arrows. We will call them hop's. Here we will also assign the output to the variable g for export below.

g = With[{baseline = -2.5 {0, 1, 2, 3}, t = Range[-2, 2, 0.01],
tdots = {-1.5, -0.5, 0.5, 1.5}},
Module[{s, dots, hop},
s = Cos[2 \[Pi] t];
dots[k_] :=
With[{td = tdots[[k]], y0 = baseline[[k]] + 0.15, dy = 0.4, r = 0.16},
{Red, Disk[{td, y0 + dy}, r], Disk[{td, y0}, r], Disk[{td, y0 - dy}, r]}
];
hop[k1_, k2_] := With[{y = baseline[[k1]] + 1, t1 = tdots[[k1]], t2 = tdots[[k2]]},
Arrow[BezierCurve[
{{t1, y}, {0.9 t1 + 0.1 t2, y + 0.5}, {0.1 t1 + 0.9 t2, y + 0.5}, {t2, y}}]
] ];
Graphics[{
Table[Line@Thread@{t, s + baseline[[k]]}, {k, 1, 4}],
Table[dots[k], {k, 1, 4}],
hop[1, 2], hop[2, 3], hop[3, 4], hop[4, 1]
}]
]
]


You want to export to a pixel oriented format like png as opposed to a photographic image format like jpg because the jpg image compression can introduce artifacts. This command will save the png file in the same directory as the notebook containing this code.

Export[FileNameJoin[{NotebookDirectory[], "dot_hops.png"}],g,ImageResolution->200]

• I appreciate that a lot thank you very much I am a beginner user of mathematica your explaination helps alot – maya Aug 1 '18 at 11:57
• Your thanks are my reward, but would you mind accepting my answer? – user7739 Aug 1 '18 at 23:55
• how I can change your code so instead of 3 balls in one site ,I would have 2 balls in site and 1 ball in the next neighbor site ? I would appreciate so much if you can answer me , thanks in advance – maya Sep 18 '18 at 9:29

If you can adapt this then Export works just fine

g1 = GraphicsColumn[{
Plot[Cos[0.0625*Pi x], {x, 0, 40*Pi}, Axes -> False,
Epilog -> {Disk[{5 Pi, 3/4}, {8, .2}], Disk[{5 Pi, 1/4}, {8, .2}],