Hi everyone. I'm trying to break the y axis on a plot. For instance, I have 2 series (points and a loess). Since the loess is a "continuous" set of points, it passes in the break section. However, with gap.plot I cant plot the loess because of this (I got the message "some values of y will not be displayed"). Here's my code: library(plotrix); #generate some data x = seq(-pi,pi,0.1); sinx = sin(x); #add leverage value sinx = c(sinx,10); xx = c(x,max(x) + 0.1); #Loess yy = loess(sinx ~ xx, span = 0.1); yy = predict(yy); #Add break between 2 and 8 gap.plot(xx,sinx,c(2,8)); #This line works fine gap.plot(xx,yy,c(2,8), add = T); #This wont plot the loess I did the graphic I would like to produce in Sigmaplot. http://img830.imageshack.us/img830/5206/breakaxis.jpg Can it be done in R ? With regards, Phil -- View this message in context: http://r.789695.n4.nabble.com/Axis-break-with-gap-plot-tp2533027p2533027.html Sent from the R help mailing list archive at Nabble.com.
On 09/10/2010 01:07 AM, Filoche wrote:> > Hi everyone. > > I'm trying to break the y axis on a plot. For instance, I have 2 series > (points and a loess). Since the loess is a "continuous" set of points, it > passes in the break section. However, with gap.plot I cant plot the loess > because of this (I got the message "some values of y will not be > displayed"). > > Here's my code: > > library(plotrix); > > > #generate some data > x = seq(-pi,pi,0.1); > sinx = sin(x); > > #add leverage value > sinx = c(sinx,10); > xx = c(x,max(x) + 0.1); > > #Loess > yy = loess(sinx ~ xx, span = 0.1); > yy = predict(yy); > > #Add break between 2 and 8 > gap.plot(xx,sinx,c(2,8)); #This line works fine > gap.plot(xx,yy,c(2,8), add = T); #This wont plot the loess > > I did the graphic I would like to produce in Sigmaplot. > > http://img830.imageshack.us/img830/5206/breakaxis.jpg >Hi Phil, The loess is being displayed, but because it is just reproducing the points already there, except for one or two, you don't see it. If you try this: gap.plot(xx,yy,c(2,8), add = TRUE,type="l"); you'll see the line, although you won't get the uptick at the end because it passes through the gap. It would require a bit of manual labor to get the same plot as your example. If you have to do just one of these, I would probably recalculate the loess fit to account for the gap and display it with "lines". If you have to do lots, I would think about writing a function to do this that you could call instead of the second call to gap.plot. Jim
Thank Jim for your answer. I actually did my own function to plot with the loess. I just calculated the intersection between the first and second horizontal gap lines with the line formed by the 2 points before and after the gap. So I can now plot the loess from both sides of the gap section. Thank again for your help, Phil -- View this message in context: http://r.789695.n4.nabble.com/Axis-break-with-gap-plot-tp2533027p2534658.html Sent from the R help mailing list archive at Nabble.com.
Hi again everyone. Anyone know if there's any limitation with gap.plot concerning the fill color of plotted markers? I would like to fill the circles with a color : library(plotrix); gap.plot(c(1,2,3,4,10), c(1,2,3,4,10), c(5,9), pch = 21, col = "red"); However, it only change the color of the line. I tried "bgcol" and some argument but without success. With regards, Phil -- View this message in context: http://r.789695.n4.nabble.com/Axis-break-with-gap-plot-tp2533027p2537540.html Sent from the R help mailing list archive at Nabble.com.