Group Abstract Group Abstract

Message Boards Message Boards

0
|
2K Views
|
2 Replies
|
1 Total Like
View groups...
Share
Share this post:

Overlay plots with epilogs

Posted 3 years ago

How can I make the 2 axes of the same scale?

Plot[x, {x, 0, 1}, 
  Epilog -> {Text[Style["y=" <> ToString[1], 10], {0.1, 0.1}]}];
Plot[2 x, {x, 0, 2}, 
  Epilog -> {Text[Style["y=" <> ToString[2], 10], {0.4, 0.8}]}];
Overlay[{%%, %}]
POSTED BY: a a
2 Replies
Posted 3 years ago

thank you that works

POSTED BY: a a

You can give both plots the same PlotRange -> {{0, 2}, {0, 4}}:

Plot[x, {x, 0, 1}, 
 Epilog -> {Text[Style["y=" <> ToString[1], 10], {0.1, 0.1}]}, 
 PlotRange -> {{0, 2}, {0, 4}}]
Plot[2 x, {x, 0, 2}, 
 Epilog -> {Text[Style["y=" <> ToString[2], 10], {0.4, 0.8}]}, 
 PlotRange -> {{0, 2}, {0, 4}}]
Overlay[{%%, %}]

Instead of Overlay, you may want to experiment with a single Plot for both functions:

Plot[{x, 2 x}, {x, 0, 2}, 
 Epilog -> {Text[Style["y=" <> ToString[1], 10], {0.1, 0.1}], 
   Text[Style["y=" <> ToString[2], 10], {0.4, 0.8}]}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard