RE: A plot of Sign[x]
- To: mathgroup at smc.vnet.net
- Subject: [mg94138] RE: [mg94074] A plot of Sign[x]
- From: "David Park" <djmpark at comcast.net>
- Date: Fri, 5 Dec 2008 05:35:16 -0500 (EST)
- References: <9090824.1228393272485.JavaMail.root@m02>
Using Mesh only shows the points that Mathematica used in plotting the curve. It is not usually the best presentation of the function. In this case we can make some improvement by: 1) Using the Exclusions option to eliminate the vertical line at x == 0. 2) Substituting a Frame for the Axes to get the scale line off the critical part of the function. Frame plots are almost always better than Axes plots of functions. (Another possibility is to use an Axis plot but use AxesOrigin -> {-5,0}. Plot[Sign[x], {x, -5, 5}, Exclusions -> {x == 0}, Mesh -> 51, PlotRange -> {-1.2, 1.2}, Axes -> None, Frame -> True] Plot[Sign[x], {x, -5, 5}, Exclusions -> {x == 0}, Mesh -> 51, PlotRange -> {-1.2, 1.2}, AxesOrigin -> {-5, 0}, Frame -> False] The following is a custom plot done with the Presentations package. Here, using CirclePoint, I mark the points at x == 0 with an outlined gray circle to mark the isolated point, and two outlined white circles to mark the excluded points. I use CustomTicks to make tick scales on the left and right that show only the important y values. Needs["Presentations`Master`"] yticks = CustomTicks[Identity, databased[{-1, 0, 1}]]; Draw2D[ {(* Draw Sign[x] excluding x == 0 *) Draw[Sign[x], {x, -5, 5}, Exclusions -> {x == 0}], (* Mark value at x == 0 *) CirclePoint[{0, Sign[0]}, 3, Black, Gray], (* Mark excluded points at y == -1 and +1 *) CirclePoint[{0, #}, 3, Black, White] & /@ {-1, 1}}, Frame -> True, FrameLabel -> {x, Sign[x]}, FrameTicks -> {{yticks, yticks}, {Automatic, Automatic}}, PlotRange -> {-1.5, 1.5}, PlotLabel -> Style["Sign[x] Showing Special Points", 16], BaseStyle -> {12}, ImageSize -> 600 ] This plot could also be made in regular Mathematica but not quite as obviously or easily. I never edit people's email addresses. For a quicker response supply a working email address (in the case that the above address IS nonworking.). David Park djmpark at comcast.net http://home.comcast.net/~djmpark From: Bert Aerts (rm X) [mailto:bert.aertsX at advalvas.beX] I tried to plot the Sign function, making clear that Sign[0]=0 by typing Plot[Sign[x], {x, -5, 5}, Mesh -> 51, PlotRange -> All] Making Mesh an odd value shows x=0. But the point at x=0 is being plot as 0.5 in stead of zero. What am I doing wrong? Mathematica 6.0.3 Linux x86_64