Prev: Display/manipulating numeric values inside a DynamicModule[]
Next: FindRoot with parameterized interpolated function from NDSolve
From: Leo Alekseyev on 4 Jul 2010 03:10 Some of my plots contain vertical lines for alignment. To make sure the lines extend from the top to the bottom of the plot frame, I typically give those lines large values for +y and -y coordinates. This has an unfortunate side effect that the directive PlotRange->All now considers my line to be a part of the plot, and rescales the plot range to display it in its entirety. Is there a way to (a) either make PlotRange->All ignore this line somehow or (b) set the +y and -y coordinates of the line to match the current plot range?.. Thanks in advance to anyone who might clarify this... --Leo
From: Daniel Huber on 4 Jul 2010 06:10 On 04.07.2010 09:10, Leo Alekseyev wrote: > Some of my plots contain vertical lines for alignment. To make sure > the lines extend from the top to the bottom of the plot frame, I > typically give those lines large values for +y and -y coordinates. > This has an unfortunate side effect that the directive PlotRange->All > now considers my line to be a part of the plot, and rescales the plot > range to display it in its entirety. Is there a way to (a) either > make PlotRange->All ignore this line somehow or (b) set the +y and -y > coordinates of the line to match the current plot range?.. > > Thanks in advance to anyone who might clarify this... > --Leo > Hi Leo, you may use scaled coordinates that run from 0..1: Plot[Sin[x], {x, 0, 10}, Epilog -> {Line[{Scaled@{0.5, 0}, Scaled@{0.5, 1}}]}] Note that you must also give the x coordinate in the 0..1 scale. cheers, Daniel
From: Bill Rowe on 4 Jul 2010 06:10 On 7/4/10 at 3:10 AM, dnquark(a)gmail.com (Leo Alekseyev) wrote: >Some of my plots contain vertical lines for alignment. To make sure >the lines extend from the top to the bottom of the plot frame, I >typically give those lines large values for +y and -y coordinates. >This has an unfortunate side effect that the directive >PlotRange->All now considers my line to be a part of the plot, and >rescales the plot range to display it in its entirety. Is there a >way to (a) either make PlotRange->All ignore this line somehow or >(b) set the +y and -y coordinates of the line to match the current >plot range?.. Here are two ways to place a vertical line on a plot without using large coordinate values for y: Plot[Cosh[x], {x, -5, 5}, Epilog -> {Red, Line@{Scaled@{.8, 0}, Scaled@{.8, 1}}}] or Plot[Cosh[x], {x, -5, 5}, GridLinesStyle -> Red, GridLines -> {{3}, None}]
From: David Park on 5 Jul 2010 06:02 The Presentations package has a command, DrawingWidths2D, that gives knowledge of the bounding box of a set of graphics primitives, which can be used while drawing other primitives. It returns the x and y ranges, the x and y centers, and the min and max values of the bounding box. For example, here we use it to find the bounding box of an ellipse produced by a ContourPlot. Needs["Presentations`Master`"] quadratic[x_, y_] := x^2 + 2 x y + 1.5 y^2 + 3 x - y + 2 {{xrange, yrrange}, {xccenter, ycenter}, {{xmin, xmax}, {ymin, ymax}}} = DrawingWidths2D[{ContourDraw[ quadratic[x, y] == 0, {x, -15, 15}, {y, -15, 15}]}] {{9.94158, 8.11799}, {-5.50227, 4.00035}, {{-10.4731, -0.531481}, {-0.0586483, 8.05934}}} Here we use it to draw the ellipse and then add a vertical line that matches the vertical range. Module[{g, xrange, yrange, xcenter, ycenter, xmin, xmax, ymin, ymax}, g = ContourDraw[quadratic, {x, -15, 15}, {y, -15, 15}, PlotRange -> All]; {{xrange, yrrange}, {xcenter, ycenter}, {{xmin, xmax}, {ymin, ymax}}} = DrawingWidths2D[{g}]; Draw2D[ {g, Line[{{xcenter, ymin}, {xcenter, ymax}}]}, PlotRange -> All, ImageSize -> 300] ] David Park djmpark(a)comcast.net http://home.comcast.net/~djmpark/ From: Leo Alekseyev [mailto:dnquark(a)gmail.com] Some of my plots contain vertical lines for alignment. To make sure the lines extend from the top to the bottom of the plot frame, I typically give those lines large values for +y and -y coordinates. This has an unfortunate side effect that the directive PlotRange->All now considers my line to be a part of the plot, and rescales the plot range to display it in its entirety. Is there a way to (a) either make PlotRange->All ignore this line somehow or (b) set the +y and -y coordinates of the line to match the current plot range?.. Thanks in advance to anyone who might clarify this... --Leo
From: Helen Read on 5 Jul 2010 06:01
On 7/4/2010 3:10 AM, Leo Alekseyev wrote: > Some of my plots contain vertical lines for alignment. To make sure > the lines extend from the top to the bottom of the plot frame, I > typically give those lines large values for +y and -y coordinates. > This has an unfortunate side effect that the directive PlotRange->All > now considers my line to be a part of the plot, and rescales the plot > range to display it in its entirety. Is there a way to (a) either > make PlotRange->All ignore this line somehow or (b) set the +y and -y > coordinates of the line to match the current plot range?.. Use GridLines. For example: f[x_] = x^2; g[x_] = x^3; Plot[{f[x], g[x]}, {x, -3, 3}, GridLines -> {{-2, 2}, None}, GridLinesStyle -> Directive[Red, Dashed]] Plot[{f[x], g[x]}, {x, -5, 5}, GridLines -> {{-2, 2}, None}, GridLinesStyle -> Directive[Red, Dashed]] Plot[{f[x], g[x]}, {x, -5, 5}, GridLines -> {{-2, 2}, None}, GridLinesStyle -> Directive[Red, Dashed], PlotRange -> {-10, 10}] GridLines scale appropriately according to the PlotRange. You can even style the GridLines individually if you like. BTW, it is helpful to post an example of what you are talking about that others can copy/paste into Mathematica and evaluate, instead of having to make up their own examples that may or may not reflect what you are talking about. -- Helen Read University of Vermont |