# Put together two ListLinePlot with right alignment

I would like to ask for some help to figure out how can i put two ListLinePlot together with right alignment. Here is what i tried to do:

absnyomplot =
ListLinePlot[
Table[{(i - 1)*5, fnyomdel[[i]]}, {i, 1, Length[fnyomdel]}],
InterpolationOrder -> 1, Mesh -> Full, PlotStyle -> Blue,
Frame -> {True, True, True, False},
FrameStyle -> {Automatic, Blue, Automatic, Automatic},
ImageSize -> Large,
FrameLabel -> {"Time[min]", "Abs pressure [kPa]"},
LabelStyle -> Directive[Large]];

abshomomplot =
ListLinePlot[
Table[{(i - 1)*5, fhomdel[[i]]}, {i, 1, Length[fhomdel]}],
InterpolationOrder -> 1, Mesh -> Full, PlotStyle -> Red,
Axes -> False, Frame -> {False, False, False, True},
FrameTicks -> {None, None, None, All},
FrameStyle -> {Automatic, Automatic, Automatic, Red},
ImageSize -> Large,
FrameLabel -> {{" ", "Temperature [\[Degree]C]"}, {" ", " "}},
LabelStyle -> Directive[Large]];

Overlay[{absnyomplot, abshomomplot}]


And the result:

So the first points of the two plots should be the on the same place on the horizontal axis.

• Thank you guys! I appreciate your answers! Jun 18, 2015 at 13:36

Use the same ImagePadding for both images.

fnyomdel = Accumulate[RandomReal[{0, 1}, 10]];
fhomdel = Accumulate[RandomReal[{0, 12}, 10]];
absnyomplot =
ListLinePlot[
Table[{(i - 1)*5, fnyomdel[[i]]}, {i, 1, Length[fnyomdel]}],
InterpolationOrder -> 1, Mesh -> Full, PlotStyle -> Blue,
Frame -> {True, True, True, False},
FrameStyle -> {Automatic, Blue, Automatic, Automatic},
ImageSize -> Large,
FrameLabel -> {"Time[min]", "Abs pressure [kPa]"},
LabelStyle -> Directive[Large], ImagePadding -> 50];

abshomomplot =
ListLinePlot[
Table[{(i - 1)*5, fhomdel[[i]]}, {i, 1, Length[fhomdel]}],
InterpolationOrder -> 1, Mesh -> Full, PlotStyle -> Red,
Axes -> False, Frame -> {False, False, False, True},
FrameTicks -> {None, None, None, All},
FrameStyle -> {Automatic, Automatic, Automatic, Red},
ImageSize -> Large,
FrameLabel -> {{" ", "Temperature [\[Degree]C]"}, {" ", " "}},
LabelStyle -> Directive[Large], ImagePadding -> 50];

Overlay[{absnyomplot, abshomomplot}]


(I took the liberty of generating the data. It would be better if you didn't post code that refer to unavailable data).

• I ran your exact code and I get a result where the Temperature scale is missing the number scale and the Time label is cut off half way up. I changed the ImagePadding to '75' from '50' to get all the labels to show. However, the Temperature scale is still missing? Any thoughts? I am running MMA 10.1.0 on OS X 10.10.3 ... Jun 18, 2015 at 13:32
• Okay wont happen again! Jun 18, 2015 at 13:32
• If I change the FrameTicks->{None, None, None, All} in the second ListLinePlot statement to FrameTicks->All, then the numeric Temperature scale appears on the plot Jun 18, 2015 at 13:48
• @Joseph If the ImagePadding is too low, it might crop the FrameLabels and/or the FrameTicks. Use a higher value and you'll see them all. Jun 18, 2015 at 13:58

As another option for a similar plot, you can rescale the data pretty easily and just plot them with the same plot command.

fnyomdel = Accumulate[RandomReal[{0, 1}, 10]];
fhomdel = Accumulate[RandomReal[{0, 12}, 10]];

ListLinePlot[
{
Transpose@{Range@Length@fnyomdel, fnyomdel}
, Rescale[
fhomdel, ({Min@#, Max@#} &@fhomdel), ({Min@#, Max@#} &@fnyomdel)]
}
, PlotStyle -> {Blue, Red}
, Frame -> True
, FrameTicks -> {Automatic
, Automatic
, None
, Transpose@({Rescale[#, {Min@#, Max@#}, {Min@fnyomdel,
Max@fnyomdel}], #} &@Range[0, 40, 10])
}
, FrameStyle -> {Black, Blue, Black, Red}
]


You have to do a little more work to rescale the axis ticks on the right, but it makes some things line up better. From there you can style it however you like.