I am using the following commands for plotting kernel density for three kinds of crops density(s22$Net_income_Total.1, bw="nrd0",adjust=1, kernel=c("gaussian"))->t plot(t, xlim=c(-30000,40000), main="Net Income Distribution", axes=F, ylim=c(0,0.00035). xlab="Value in Rupees") par(new=T) density(s33$Net_income_Total.1, bw="nrd0",adjust=1, kernel=c("gaussian"))->u plot(u, xlim=c(-30000,40000), axes=F, main="", col="red", ylim=c(0,0.00035)) par(new=T) density(s44$Net_income_Total.1, bw="nrd0",adjust=1, kernel=c("gaussian"))->v plot(v, xlim=c(-30000,40000), col="blue", axes=F, main="", ylim=c(0,0.00035)) the problem is that in the graph that is drawn 1. the xlab gets hidden with the [N= and the bandwidth=] values 2. when i do par(new=T) this N and bandwidth value appears multiple times..overlapping each time and making the graph look untidy.. Is there any way of making these N and Bandwidth values not appear in the graph? Thanks -- -- [[alternative HTML version deleted]]
On Apr 3, 2011, at 6:56 AM, Muzna Alvi wrote:> I am using the following commands for plotting kernel density for > three > kinds of crops > > density(s22$Net_income_Total.1, bw="nrd0",adjust=1, > kernel=c("gaussian"))->t > plot(t, xlim=c(-30000,40000), main="Net Income Distribution", axes=F, > ylim=c(0,0.00035). xlab="Value in Rupees") > par(new=T) > density(s33$Net_income_Total.1, bw="nrd0",adjust=1, > kernel=c("gaussian"))->u > plot(u, xlim=c(-30000,40000), axes=F, main="", col="red", > ylim=c(0,0.00035)) > par(new=T) > density(s44$Net_income_Total.1, bw="nrd0",adjust=1, > kernel=c("gaussian"))->v > plot(v, xlim=c(-30000,40000), col="blue", axes=F, main="", > ylim=c(0,0.00035)) > > the problem is that in the graph that is drawn > > 1. the xlab gets hidden with the [N= and the bandwidth=] values > 2. when i do par(new=T) this N and bandwidth value appears multiple > times..overlapping each time and making the graph look untidy.. > > > Is there any way of making these N and Bandwidth values not appear > in the > graph?Why not just set ylab="" in subsequent calls to plot? -- David Winsemius, MD West Hartford, CT
On Apr 3, 2011, at 7:55 AM, David Winsemius wrote:> > On Apr 3, 2011, at 6:56 AM, Muzna Alvi wrote: > >> I am using the following commands for plotting kernel density for >> three >> kinds of crops >> >> density(s22$Net_income_Total.1, bw="nrd0",adjust=1, >> kernel=c("gaussian"))->t >> plot(t, xlim=c(-30000,40000), main="Net Income Distribution", axes=F, >> ylim=c(0,0.00035). xlab="Value in Rupees") >> par(new=T) >> density(s33$Net_income_Total.1, bw="nrd0",adjust=1, >> kernel=c("gaussian"))->u >> plot(u, xlim=c(-30000,40000), axes=F, main="", col="red", >> ylim=c(0,0.00035)) >> par(new=T) >> density(s44$Net_income_Total.1, bw="nrd0",adjust=1, >> kernel=c("gaussian"))->v >> plot(v, xlim=c(-30000,40000), col="blue", axes=F, main="", >> ylim=c(0,0.00035)) >> >> the problem is that in the graph that is drawn >> >> 1. the xlab gets hidden with the [N= and the bandwidth=] values >> 2. when i do par(new=T) this N and bandwidth value appears multiple >> times..overlapping each time and making the graph look untidy.. >> >> >> Is there any way of making these N and Bandwidth values not appear >> in the >> graph? > > Why not just set ylab="" in subsequent calls to plot?Sorry, I meant xlab="".>-- David Winsemius, MD West Hartford, CT
It is better to replace your later calls to plot with calls to lines instead, then you don't need to use par(new=T) which as you see tends to cause problems. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Muzna Alvi > Sent: Sunday, April 03, 2011 4:56 AM > To: r-help at r-project.org > Subject: [R] kernel density plot > > I am using the following commands for plotting kernel density for three > kinds of crops > > density(s22$Net_income_Total.1, bw="nrd0",adjust=1, > kernel=c("gaussian"))->t > plot(t, xlim=c(-30000,40000), main="Net Income Distribution", axes=F, > ylim=c(0,0.00035). xlab="Value in Rupees") > par(new=T) > density(s33$Net_income_Total.1, bw="nrd0",adjust=1, > kernel=c("gaussian"))->u > plot(u, xlim=c(-30000,40000), axes=F, main="", col="red", > ylim=c(0,0.00035)) > par(new=T) > density(s44$Net_income_Total.1, bw="nrd0",adjust=1, > kernel=c("gaussian"))->v > plot(v, xlim=c(-30000,40000), col="blue", axes=F, main="", > ylim=c(0,0.00035)) > > the problem is that in the graph that is drawn > > 1. the xlab gets hidden with the [N= and the bandwidth=] values > 2. when i do par(new=T) this N and bandwidth value appears multiple > times..overlapping each time and making the graph look untidy.. > > > Is there any way of making these N and Bandwidth values not appear in > the > graph? > > Thanks > > -- > -- > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.