Possible Duplicate:
1 Plot, 2 Scale/Axis
I aim to combine two plots in which the YY axes have different scales: one goes PlotRange->{0,100}
while the other goes PlotRange->{0,2.5*^-5}
. I've been trying to do this for several hours and, although I think I'm almost there, I cant seem to make it.
Here's the input code:
(*not very important, is one of the functions to be plotted*)
P[st_, base_, int_] :=
Module[{nper, period, length, tcap, tarteriols, tvenuls, ttotaloxi},
period = 60/((4/3 Pi (0.1/2)^3)/48);
length = 2;
nper = (t - st)/period;
If[0 <= (t - st) - period Floor@nper < length, base + int, base]
]
The problem is in this one for sure:
Combineplots[{hout_, maxrange_}, {t_, t0_, tf_}] :=
Module[{relgraf, ihgraf, relrange, ih2o2range, relticks,
ih2o2ticks},
relgraf =
Plot[Evaluate[{10 t} /. setpars /. pa[h2o2out]], {t, t0, tf},
LabelStyle -> {FontFamily -> "Arial", Bold, 40},
PlotStyle -> {{Thickness[0.011],
Darker[Green, 0.5]}, {Thickness[0.011],
Darker[Red, 0.2]}, {Thickness[0.007],
Darker[Blue, 0.3]}, {Thickness[0.007], Darker[Orange, 0.3]}}];
ih2o2graf =
Plot[Pulse[2, 1*^-9, h2o2out], {t, t0, tf},
LabelStyle -> {FontFamily -> "Arial", Bold, 40},
PlotStyle -> {Thickness[0.007], Black}];
relrange = ({0, 100});
ih2o2range = ({0, maxrange});
Show[relgraf,
ih2o2graf /.
Graphics[graf_, s___] :>
Graphics[
GeometricTransformation[graf,
RescalingTransform[{{0, 10}, ih2o2range}, {{0, 10},
relrange}]], s], Axes -> True,
Frame -> {{True, True}, {True, False}},
FrameStyle -> AbsoluteThickness[3],
FrameTicks -> {{Automatic, {{1/200000, "5"}, {1/100000, "10"}, {3/
200000, "15"}, {1/50000, "20"}, {1/40000, "25"}, {3/100000,
"30"}}}, {Automatic, None}}, ImageSize -> Medium]]
Combineplots[{2*^-5, 3*^-5}, {t, 0, 10}]
I've been able to plot both together correctly, with exception for the right YY axis:
Yet, the ticks theoretically are placed at the correct place (using the same tick marks in a single plot I get the correct marking:)
Do you guys think you can give me some clue please? Thanks so much!
Overlay
and gives almost the same result with many less code lines than the ones I was using. Superimposition of both graphs isn't perfect yet, but a bit of fine tuning and it works too. Problably playing around withImagePadding
and thats it! thanks again! $\endgroup$