       • To: mathgroup at smc.vnet.net
• Subject: [mg98578] Re: Adding text to RegionPlot
• From: Helen Read <hpr at together.net>
• Date: Mon, 13 Apr 2009 03:34:16 -0400 (EDT)
• References: <grs67t\$qfq\$1@smc.vnet.net>

```Jim Rockford wrote:
> I would like to add text at specific (x,y) locations for a 2D graphic
> generated by RegionPlot (meaning, I'd rather not use the graphic tool
> and add text by hand).  Is there a way to do this?  I get mathematica
> complaints that RegionPlot is not a "type of graphics."
>
> For example, this code fails:
>
> RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange ->
> {{0, 3}, {0, 1}},Graphics[Text["mytext", {1.5, 1}]]
>
> Apparently I'm using Graphics[Text[]]  incorrectly.  How can I get
> such a simple function of putting text at a specific location to work
> in RegionPlot?

RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1},
PlotRange -> {{0, 3}, {0, 1}}, Epilog -> Text["my text", {1.3, 1}]]

This will cut off your text, though, since it is centered at {1.3,1}.
You need to leave a bit of vertical room for it, something like this.

RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1},
PlotRange -> {{0, 3}, {0, 1.2}}, Epilog -> Text["my text", {1.3, 1}]]

You can also combine graphics with Show, instead of packing a lot into
Epilog.

plot1 = RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}];
plot2 = Graphics[{Red, FontSize -> 14, FontFamily -> "Helvetica",
Text["My text", {1.3, 1}]}];
Show[{plot1, plot2}, PlotRange -> {{0, 3}, {0, 1.2}}]

Note also that you don't need RegionPlot for your example.

plot1 = Plot[1/x^2, {x, 1, 3}, Filling -> 0];
plot2 = Graphics[{Red, FontSize -> 14, FontFamily -> "Helvetica",
Text["My text", {1.3, 1}]}];
Show[{plot1, plot2}, PlotRange -> {{0, 3}, {0, 1.2}},
AxesOrigin -> {0, 0}]

--