3
$\begingroup$

I have these two plots

enter image description here

{ Plot[Sin[x], {x, 0, 10}, PlotStyle -> Blue, AxesLabel -> {"x", None}],  
Plot[Cos[x], {x, 0, 10}, PlotStyle -> Green, AxesLabel -> {"y", None}]}

I want to have the green plot such that the variable $y$ increases from right to left. Then, combine these two plots to get a picture as below

enter image description here

Thanks in advance for any hints or comments.

$\endgroup$

2 Answers 2

6
$\begingroup$
plots = {Plot[Sin[x], {x, 0, 10}, PlotStyle -> Blue,  AxesLabel -> {"x", None}], 
   Plot[Cos[x], {x, 0, 10}, PlotStyle -> Green, AxesLabel -> {"y", None}]};

Show[plots[[1]], plots[[2]] /. Line[x_] :> Line[{-1, 1} # & /@ x], 
 PlotRange -> All, 
 Ticks -> {Transpose[{#, Abs@#} &@Range[-10, 10]], Automatic}, 
 ImagePadding -> 20, PlotRangeClipping -> False, 
 Epilog -> {Text["y", Offset[{-10, 0}, {-10, 0}], Right]}]

enter image description here

Also

Show[plots[[1]], 
 MapAt[GeometricTransformation[#, ReflectionTransform[{-1, 0}]] &, plots[[2]], {1}],
 PlotRange -> All, 
 Ticks -> {Transpose[{#, Abs@#} &@Range[-10, 10]], Automatic},
 ImagePadding -> 20, 
 PlotRangeClipping -> False, 
 Epilog -> {Text["y", Offset[{-10, 0}, {-10, 0}], Right]}]

same picture

$\endgroup$
6
$\begingroup$

Set the ScalingFunctions -> {{-# &, -# &}, {# &, # &}}.

Show[Plot[Sin[x], {x, 0, 10}, PlotStyle -> Blue, 
  AxesLabel -> {"x", None}], 
 Plot[Cos[x], {x, 0, 10}, PlotStyle -> Green, 
  AxesLabel -> {"y", None}, 
  ScalingFunctions -> {{-# &, -# &}, {# &, # &}}], PlotRange -> All]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks. But I want to have the axis values for the green curve positive, i.e. from $0$ to $10$. @cvgmt $\endgroup$
    – Martha97
    Feb 24, 2022 at 8:48

Your Answer

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

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