1

I'm plotting my data points and I want to compare it to the experimentally accepted values. How can I apply the graphics option as shown below, I want to add a rectangular region to indicate the bound on the accepted values.Image

ListLogLinearPlot[data2, AxesLabel -> {Subscript[n, s], r}, LabelStyle -> {Black, 13},
PlotStyle -> Red, PlotRange -> {{0.94, 1}, Full}, PlotMarkers -> {Automatic, Medium},
Prolog -> {LightBlue, Rectangle[{0.94, 0}, {0.97, 0.11}]}, Epilog -> {Thick, Black, Dashed, Line[{{0.94, 0.11}, {1, 0.11}}]}]
mathemania
  • 713
  • 5
  • 12

1 Answers1

3

Generally you can use the Prolog option and standard Graphics primitives like Rectangle (example) but for the given style you can use Filling directives in Plot itself, like this:

Plot[
  {5, 8, 2 Sin[x] + x, x - 5 Sinc[x]}, {x, 0, 15}, 
  PlotStyle -> Join[{None, None}, ColorData[97, "ColorList"]], 
  Filling -> {1 -> {15, LightBlue}, {2 -> {12, Yellow}}}
]

enter image description here

The Filling method can be a little harder to set up but it scales well when changing PlotRange etc.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • I have added the code that I have written but it's not working. I have also added a dashed line to indicate the bound on the y-axis, the shaded region that I want is a bound on the x-axis. The image that I have shown is just an example of what I want to achieve (colored region). – mathemania Jun 06 '17 at 06:51
  • @mathemania If you are using a ListPlot variation the Filling method won't work directly, so I suggest you use Prolog. Without a copy of your data2 I can't evaluate your plot; perhaps you would include a minimal example? – Mr.Wizard Jun 06 '17 at 06:59
  • I have used Prolog, not Filling. Also, Epilog doesn't work. – mathemania Jun 06 '17 at 07:07
  • @mathemania Yes I see, but I don't want to have to craft dummy data just to run your code; please do that yourself. – Mr.Wizard Jun 06 '17 at 07:08
  • My data points are in an excel file, maybe a linear function with 3 points would be enough just to show an example, maybe the domain is x=1,2,3 and the values are y=1,2,3 for a linear function y=x. – mathemania Jun 06 '17 at 15:16