1
$\begingroup$

I'm trying to plot a graph and set Frame width and height by given numbers. However, I found I could only fix the Frame height, the Frame width varys with data plotted. For example, compare

 img1 = ListPlot[{0.5*#, 5 #} & /@ Range@100, Joined ->True,
PlotRange -> {Automatic, {100, 300}}, PlotStyle -> Black,  
LabelStyle -> 18, ImageSize -> 1 -> {5, 1.6}, Frame -> True, 
Joined -> True, FrameLabel -> {"X", "Y"}, AspectRatio -> 3]

and

img2 = ListPlot[{0.1*# + 1, 5 #} & /@ Range@100, Joined -> True, 
PlotRange -> {Automatic, {100, 300}}, PlotStyle -> Black, 
LabelStyle -> 18, ImageSize -> 1 -> {5, 1.6}, Frame -> True, 
Joined -> True, FrameLabel -> {"X", "Y"}, AspectRatio -> 3]

The Frames of img1 and img2 have same height but different width. How to make their width equal?

I'm using Mathematica 12 on windows 10.

$\endgroup$
  • 2
    $\begingroup$ The problem is that you're specify conflicting options - ImageSize -> 1 -> {5, 1.6} specifies that 1 unit in the plot should correspond to 5 & 1.6 in x & y respectively. And this seems to take priority over AspectRatio. If you change it to ImageSize -> 1 -> 1.6, it will work as expected $\endgroup$ – Lukas Lang Sep 9 at 11:47
  • $\begingroup$ To adjust for different horizontal plot ranges in img1 and img2, change the image size option in img2 to ImageSize -> 1 -> {5 50/11, 1.6} $\endgroup$ – kglr Sep 9 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.