4
$\begingroup$

How can I make the content inside these two images are aligned and the region outside of the plots are also same?
I don't want to combine two images together. I want to make them having the same size and symmetric so they look good when I insert they somewhere (not necessary on the same table).

enter image description here

plot1 = Plot[x, {x, 1, 3.0001}, GridLines -> {Range[3], Range[3]}, 
 Frame -> {{True, True}, {True, False}},
 FrameTicks -> {Range[1, 3, 1], Range[0, 3, 1]},
 Frame -> {{True, False}, {True, False}},
 FrameLabel -> {x, y},
 ImageSize -> 300, PlotRangePadding -> None]
plot2 =Plot[-x, {x, -2.0001, 0}, 
 GridLines -> {Range[-2, 0, 1], Range[0, 2, 1]}, 
 Frame -> {{False, True}, {True, False}},
 FrameTicks -> {Range[-2, 0, 1], Range[0, 2, 1]}, 
 Frame -> {{False, True}, {True, False}},
 FrameLabel -> {{False, y}, {x, False}},
 ImageSize -> 300, PlotRangePadding -> None]

Assume that I export them as PNG or PDF and insert into word or LaTeX.

Export["plot1.png", plot1];
Export["plot2.png", plot2];

enter image description here

As you can see here the frame axes are misaligned. I want to make them aligned. In this case the misalignment doesn't look too bad but in some cases it become worse.

$\endgroup$
4
  • 1
    $\begingroup$ Look at GraphicsGrid $\endgroup$ Jul 10, 2022 at 20:42
  • 1
    $\begingroup$ @DanielHuber but I don't want to combine them together. The two plots have the same range and same labels so I think there is an easier way to do that? $\endgroup$
    – hana
    Jul 10, 2022 at 21:32
  • 1
    $\begingroup$ I seems like ImagePadding -> 30 works here. $\endgroup$
    – hana
    Jul 10, 2022 at 22:04
  • 2
    $\begingroup$ I think this is a valid on-topic question. Why the close votes? The OP want the axis to have a well-defined size, and it's not necessarily obvious how to achieve that. Please leave this question open. If the answer is obvious, then please post a detailed explanation. What is the relationship between ImageSize, ImagePadding and the axis size? $\endgroup$
    – rhermans
    Jul 12, 2022 at 8:05

1 Answer 1

2
$\begingroup$

If I understand you right, the problem is that because the label "y" is on the right side of the second plot, it is displaced horizontally to the left. Is that right? If yes, I can propose a simple workaround. Combine the second plot with the Spacer using Row. Play with the space size. My filling that 15 is OK:

plot1 = Plot[x, {x, 1, 3.0001}, GridLines -> {Range[3], Range[3]}, 
  Frame -> {{True, True}, {True, False}}, 
  FrameTicks -> {Range[1, 3, 1], Range[0, 3, 1]}, 
  Frame -> {{True, False}, {True, False}}, FrameLabel -> {x, y}, 
  ImageSize -> 300, PlotRangePadding -> None]
plot2 = Row[{Spacer[15], 
   Plot[-x, {x, -2.0001, 0}, 
    GridLines -> {Range[-2, 0, 1], Range[0, 2, 1]}, 
    Frame -> {{False, True}, {True, False}}, 
    FrameTicks -> {Range[-2, 0, 1], Range[0, 2, 1]}, 
    Frame -> {{False, True}, {True, False}}, 
    FrameLabel -> {{False, y}, {x, False}}, ImageSize -> 300, 
    PlotRangePadding -> None]
   }]

returning the following:

enter image description here

A later edit:

OK, I understand your sequence of actions and repeated it with plot1 and plot2 from my answer. Here is the result, provided I insert is into the Word file.

enter image description here

Please note that in the Word document, you can adjust the images individually, so the problem is not that accute.

In the tex file (which I then show as the pdf one) it looks as follows:

enter image description here

I achieved that with the spacer value equal to 40. So, I do not see what does not fit your requirements.

I hope it helps. Have fun!

$\endgroup$
5
  • $\begingroup$ Sorry that I probably didn't explain it clear enough. I want to export each image to PDF and then you can imagine like print them and put them with left aligned so they also have the content aligned as well. $\endgroup$
    – hana
    Jul 17, 2022 at 9:12
  • $\begingroup$ You still explain unclearly. The process you describe looks too complex. The reason is unclear. It is also not specific enough. Do you have in mind a kind of Word document in which you want to insert the PDF images? Or a PowerPoint one? Alternatively, can it be that a Mathematica document with images is OK with you? $\endgroup$ Jul 18, 2022 at 15:40
  • $\begingroup$ OK, let me make a word file and then update it. I think that is a good idea. $\endgroup$
    – hana
    Jul 19, 2022 at 1:44
  • $\begingroup$ I just updated it in my post. $\endgroup$
    – hana
    Jul 19, 2022 at 2:16
  • $\begingroup$ Please dee the edit $\endgroup$ Jul 19, 2022 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.