[R] [sm.density.compare] scale up y-axis and additional line type
Xianwen Chen
xchen at dr.com
Tue Oct 1 20:43:23 CEST 2013
Thanks Jim,
The picture width is adjusted. That was great help! I really appreciate it.
Does lwd mean 'line width'? I'm not exactly sure how that will help. Can
you please explain the intuition behind it?
Can I also ask another question? My graph is made from 7 plots from
sm.density.compare(). These 7 plots are put together by:
par(mfrow=c(4,2))
To make all 7 plots comparable, I specify y- and x-axis ranges. Here is
the sample code for one of the plots:
sm.density.compare(
c(sample_1, sample_2), # sample_1 and sample_2 are two
vectors, each corresponding to a sample
rep(1:2, rep(140, 2)),
lty = c(1, 3),
lwd = c(1, 3), # This change was made by taking your
suggestion.
col = c("black", "black"),
xlab="Sample",
xlim=c(-40, 60),
ylim=c(0, 0.15)
)
legend("topright", c("MMNL", "GMNL"), lty = c(1, 3), cex = 1)
Somehow, xlim and ylim do not have an effect. I did not have this
problem when I was running R in Arch Linux; but now I'm using Debian Linux.
Thanks!
Kind regards,
Xianwen
Jim Lemon wrote:
> On 10/01/2013 08:17 AM, Xianwen Chen wrote:
>> Dear fellows,
>>
>> The two questions are on sm.density.compare(). I compare kernel density
>> estimates of two arrays of data.
>>
>> I'd like to scale up y-axis so that I can show better the differences in
>> y values. English is not my first language so I'll try to explain it. I
>> would like to stretch y-axis a bit longer but not to change the range of
>> y values. How can I do this?
>>
>> Second, I'm using a solid line for one array of date and a dashed line
>> for another array of data. The difference is not easy to see, because
>> the two curves are approximate to some degree. Is it possible to plot
>> one array of data with *, instead of dash?
>>
> Hi Xianwen,
> You can specify the width and height of the graphics device:
>
> dev.new(height=9)
>
> OR
>
> png("myplot.png",height=600)
>
> or some other type of device. This will produce a plot that is
> noticeably higher than it is wide. For the second question, try:
>
> lty=3,lwd=3
>
> Jim
>
More information about the R-help
mailing list