Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Based on previous posts about plotting two y axes on the same x axis, I wrote this function:

plotyy[x_, y1_, y2_] := Module[{xy1, xy2, p1, p2},
  xy1 = Table[{x[[i]], y1[[i]]}, {i, Length[x]}];
  xy2 = Table[{x[[i]], y2[[i]]}, {i, Length[x]}];
  p1 = ListLinePlot[xy1, ImagePadding -> 25, 
    Frame -> {True, True, False, False}, Axes -> False];
  p2 = ListLinePlot[xy2, ImagePadding -> 25, Axes -> False, 
    Frame -> {False, False, False, True}, 
    FrameTicks -> {None, None, None, All}, PlotStyle -> Red];
  Rasterize[Overlay[{p1, p2}], RasterSize -> 600, ImageSize -> 600]]

which takes three lists with the same length and plots y1 and y2 on x. I've values for image quality by RasterSize and ImageSize for using the plot in my report but for different plots it may need different values for those two options.

How can I can set the optimum values for RasterSize and ImageSize in my function?

Thanks, Amin.

share|improve this question

1 Answer 1

Good to know how to auto-adjust the optimum value.

However, when auto-adjust value does not satisfy our demands, we could adjust the values, and see which is best.

Another Option is ImageResolution For Example:

plotyy[x_,y1_,y2_,a_,b_]:=Module[{xy1,xy2,p1,p2},xy1=Table[{x[[i]],y1[[i]]},    {i,Length[x]}];
xy2=Table[{x[[i]],y2[[i]]},{i,Length[x]}];
p1=ListLinePlot[xy1,ImagePadding->25,Frame->{True,True,False,False},Axes->False];
p2=ListLinePlot[xy2,ImagePadding->25,Axes->False,Frame->{False,False,False,True},FrameTicks->{None,None,None,All},PlotStyle->Red];
Rasterize[Overlay[{p1,p2}],RasterSize->500+a,ImageSize->600,ImageResolution->500+b]]

GraphicsGrid@Table[plotyy[{{1,1},{2,2}},{{3,3},{4,2}},{{2,2},{3,3}},a,b],{a,0,200,50},{b,0,200,50}]

of course, you could use Manipulate to adjust without too many pictures.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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