hi, i am sure that this is a trivial question but i have not been able to find an answer by searching the mailing lists. i want to plot points on a graph, joined by lines. the command that i am using is points(x, y, type = "b", pch = 21) this plots nice open circles at the data points and draws lines between them. however, the lines do not come all the way up to the edge of the circles but stop some small distance away so that there is an empty "margin" around the circles. is there a way to get rid of this margin? my first guess was that there would be an option to par() but i did not find anything there. any suggestions would be appreciated. thanks! best regards, andrew. -- Andrew B. Collier Physicist Waves and Space Plasmas Group Hermanus Magnetic Observatory Honorary Senior Lecturer tel: +27 31 2601157 Space Physics Research Institute fax: +27 31 2607795 University of KwaZulu-Natal, Durban, South Africa gsm: +27 83 3813655
Hi, Try the following, plot(1:10,rnorm(10),t="o") ## fill the points in white plot(1:10,rnorm(10),t="o",pch=21,bg="white") You could also try this with Grid graphics, library(gridExtra) # like type="o" grid.barbed(space=0) # like type="b" grid.barbed(space=1) # like the example above, but without filling the dots grid.barbed(space=0.5) (I may be wrong but don't recall that this parameter is tunable with base graphics) HTH, baptiste On 14 December 2010 16:33, Andrew Collier <collierab at gmail.com> wrote:> hi, > > i am sure that this is a trivial question but i have not been able to > find an answer by searching the mailing lists. i want to plot points on > a graph, joined by lines. the command that i am using is > > points(x, y, type = "b", pch = 21) > > this plots nice open circles at the data points and draws lines between > them. however, the lines do not come all the way up to the edge of the > circles but stop some small distance away so that there is an empty > "margin" around the circles. is there a way to get rid of this margin? > my first guess was that there would be an option to par() but i did not > find anything there. any suggestions would be appreciated. > > thanks! > > best regards, > andrew. > > -- > Andrew B. Collier > > Physicist > Waves and Space Plasmas Group > Hermanus Magnetic Observatory > > Honorary Senior Lecturer ? ? ? ? ? ? ? ? ? ? ? ? ? ? tel: +27 31 2601157 > Space Physics Research Institute ? ? ? ? ? ? ? ? ? ? fax: +27 31 2607795 > University of KwaZulu-Natal, Durban, South Africa ? ?gsm: +27 83 3813655 > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Andrew Collier <collierab <at> gmail.com> writes:> i am sure that this is a trivial question but i have not been able to > find an answer by searching the mailing lists. i want to plot points on > a graph, joined by lines. the command that i am using is > > points(x, y, type = "b", pch = 21) > > this plots nice open circles at the data points and draws lines between > them. however, the lines do not come all the way up to the edge of the > circles but stop some small distance away so that there is an empty > "margin" around the circles. is there a way to get rid of this margin? > my first guess was that there would be an option to par() but i did not > find anything there. any suggestions would be appreciated.Does type="o" do what you want? (See ?plot ) However, this actually overplots (which would be OK with filled point types, or if you don't care if you have lines running across your open points) -- it doesn't draw the line "up to the edge of the point". It looks like the size of the spacing is hard-coded at a fairly deep level: in plot.c, within the do_plot_xy function, there is a spacing factor which seems to be encoded as "half the width of standard character in the current plotting coordinates". Ben Bolker