Hot answers tagged overlay
18
Answers to your 4 questions step by step to see how each of these changes the composite plot:
1. The image padding around the two images differs so you need to set a fixed value for each. With ImagePadding -> {{50, 50}, {50, 10}} as an option for both plots I get this:
2. ChartLabels -> Placed[Style[#, "Text"] & /@ labels, Below],ImagePadding ...
16
Often I find it easier to construct such graphics directly from Graphics primitives.
First your data:
purple = RGBColor[97/255, 16/255, 106/255];
orange = RGBColor[245/255, 132/255, 31/255];
labels = {"FY15 Q1/2", "FY15 Q3/4", "FY16 Q1/2", "FY16 Q3/4",
"FY17 Q1/Q2", "FY17 Q3/Q4", "FY18 Q1/2", "FY18 Q3/4"};
starvedTime = {7.55, 11.23, 8.58333, ...
8
k = Import["traffic.avi", "ImageList"];
a = RandomReal[{0, 1}, 10];
s[n_] := ListLinePlot[a[[1 ;; n]], PlotStyle ->{Thick, White}, PlotRange ->{{1, 10}, {0, 1}}]
Table[ImageCompose[k[[n]], s[n]], {n, 10}]
5
I present a solution qualitatively similar to belisarius's, but done somewhat differently:
(* import an AVI frame-by-frame *)
imgs = ExampleData /@ ExampleData[{"TestAnimation", "ToyVehicles"}, "Frames"];
(* some plots *)
plots = Table[Plot[Sin[x], {x, -$MachineEpsilon, u}, Axes -> None, Frame -> True,
Epilog -> ...
4
To get a rolling plot you can change the PlotRange with time, something like this:
(* fake movie frames *)
image[t_] := RandomImage[{0, 1}, {150, 150}]~Blur~3
(* make up some data to plot *)
data = Accumulate[RandomReal[{-1, 1}, {100}]];
range = {Min[data], Max[data]};
(* define the rolling plot *)
rollingplot[t_, n_] := ListLinePlot[data[[;; t]],
...
4
If you import the avi using the option GraphicsList then you immediately have a variable which is a list with all the frames. For instance:
imagelist = Import["...file.avi","GraphicsList"]
You can then create an animation with this imagelist and superpose the frame numbers (or whatever other numbers you want using Show inside the Animate function):
...
4
I don't think the third argument of Overlay can be used to do what you want. An alternative is to change the active layer dynamically using EventHandler as in
DynamicModule[{layer = 1},
EventHandler[
Overlay[{Slider2D[], Graphics[{Opacity[.2], Disk[]}]}, All,
Dynamic[layer]], {{"MouseClicked", 2} :> ((layer = layer /. {1 -> 2, 2 -> 1}))},
...
4
data = 1000 RandomVariate[GammaDistribution[3, .5], 10^4];
distrib = HistogramDistribution[data];
Overlay[{DiscretePlot[CDF[distrib, x], {x, 0, Max[data]},
ImageSize -> {600, 400}, Frame -> {{False, True}, {False, False}},
FrameTicks -> {{None, Range[0.1, 1, .1]}, {None, None}},
ImagePadding -> {{50, 100}, {15, 25}}],
Histogram[data, ...
4
Another way to do that is to use Show:
LocatorPane[Dynamic[{pt1, pt2, pt3, pt4}],
Show[Image[img],
Graphics[{Orange, Opacity[.4],
Dynamic@MultiContourPolygon[{{pt1, pt2, pt3,
pt4}, {{0, 0}, {d[[1]], 0}, d, {0, d[[2]]}}}]},
ImagePadding -> 0]]]
With this solution you do not have to specify any PlotRange or ImageSize.
3
You need to specify the Plot Range:
LocatorPane[Dynamic[{pt1, pt2, pt3, pt4}],
Overlay[{Image[img, ImageSize -> 400],
Graphics[{Orange, Opacity[.4],
Dynamic@MultiContourPolygon[{{pt1, pt2, pt3,
pt4}, {{0, 0}, {d[[1]], 0}, d, {0, d[[2]]}}}]},
ImagePadding -> 0, ImageSize -> 400,
PlotRange -> Transpose[{{0, 0}, ...
3
Overlay's second parameter specifies which layers are visible and in what order. The third parameter specifies which layer can be interacted with. For your usage you can use the Overlay[layers, All, 1] form.
Here's a small demonstration for Overlay. I got a little carried away <_< but it should make clear what the second parameter can be used for.
...
1
This is related to this recent question:
relative scale of elements in ImageCompose
My answer is similar:
LocatorPane[Dynamic[{pt1, pt2, pt3, pt4}],
Show[
Rasterize @ img,
Epilog ->
{Orange, Opacity[.4],
Dynamic@MultiContourPolygon[{{pt1, pt2, pt3, pt4}, {{0, 0}, {d[[1]], 0},
d, {0, d[[2]]}}}]}
]
]
This way there is no need ...
Only top voted, non community-wiki answers of a minimum length are eligible

