Re: Advanced plotting
- To: mathgroup at smc.vnet.net
- Subject: [mg91991] Re: Advanced plotting
- From: "David Park" <djmpark at comcast.net>
- Date: Tue, 16 Sep 2008 19:23:39 -0400 (EDT)
- References: <gal3jl$e1b$1@smc.vnet.net>
I have to admit that this was a bit of work because I never tried to make a plot with an x-axis break before, but this can be done with the Presentations package. I plot BesselJ[5,x] and x^2 on the same plot with the y scale on the left going from -0.4 to 0.4 and on the right going from 0 to 2500. The scale on the right was produced with CustomTicks. The x^2 function and scale are shown in Red. The functions are shown in the domain [0,10] and [40,50] with a break, using a dashed line and "//" in the middle. Since we can't have several partial scales on an axis with Mathematica, I used two XTickLines from Presentations to produce the x scales from 0 to 10 and 40 to 50. This whole process might be automated if we were going to do a lot of it. We have to do a y scaling transformation on the x^2 function in both its plotting and in the CustomTicks. We have to do x domain shifting for both functions in the separated domain [40,50]. The x-axis and its labeling are essentially hand crafter. Needs["Presentations`Master`"] yrightticks = CustomTicks[-.4 + .00032 # &, {0, 5200, 500, 5}, CTNumberFunction -> (Style[#, Red] &)]; Draw2D[ {Draw[BesselJ[5, x], {x, 0, 10}], Draw[BesselJ[5, x + 25], {x, 15, 25}], Red, Draw[-0.4` + 0.00032` x^2, {x, 0, 10}], Draw[-0.4` + 0.00032` (x + 25)^2, {x, 15, 25}], (* Draw the x axis in two pieces *) Black, {AbsoluteDashing[{4}], Line[{{10, -.4}, {25, -.4}}]}, Text[Style["//", 12, Bold], {12.5, -.4}], XTickLine[{0, 10, -.4}, {0, 10}, {0, 10, 5}, 5, XLabTickSpecs -> {0.02, 0}, XUnLabTickSpecs -> {.01, 0}], XTickLine[{15, 25, -.4}, {40, 50}, {40, 50, 5}, 5, XLabTickSpecs -> {0.02, 0}, XUnLabTickSpecs -> {.01, 0}], Text["x" // TraditionalForm, {12.5, -.45}]}, AspectRatio -> .6, Frame -> {False, True, False, True}, FrameTicks -> {None, Automatic, None, yrightticks}, FrameLabel -> {None, BesselJ[5, x], None, x^2}, RotateLabel -> False, PlotRange -> {{0, 25}, {-.40, .40}}, PlotRangePadding -> 0, PlotRangeClipping -> False, ImagePadding -> {{60, 50}, {30, 10}}, PlotLabel -> "Two Scale Plot with x Axis Break", BaseStyle -> {FontSize -> 12}, ImageSize -> 500] -- David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ <kazik.lakomy at gmail.com> wrote in message news:gal3jl$e1b$1 at smc.vnet.net... > Hi, > I am wondering is there a possibility in Mathematica 6 to use two > different scales on vertical axis- one scale on the left one and the > other on the right one (with a horizontal axis being common for both > the vertical ones). The thing is I would like to plot two functions > that have the same "x-domain" but completely different "y-domain". If > I used the standard plotting procedure then if a first function (with > values about 100) can be easily seen on the plot, the values of the > other are to small (close to zero) to be seen. The solution would be > to set two independent Y axes, however I don't know if there is the > possibility in Mathematica 6 (I have seen such a plots in scientific > papers but maybe done with some other application). > The second question is is there a possibility to make breaks in axes. > What I mean is that I have a plot with let say X domain [0,50], but I > am only interested in two parts of it, say [0,10] and [40,50], so is > it possible to set a kind of an option in Plot command? Such a "trick" > is also quite common in scientific papers with characteristic "\\" on > axis in a place where the "break" is made (I know for example how to > do it in Origin and there is quite an easy task). > I have been searching for the staff quite long and haven't found any > solution yet so I would be really grateful if someone would help me > with the issue. > Best regards, > Kazik >