[R] How to reduce the (whitespace) gap between boxplots

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Sun Jul 17 22:41:57 CEST 2022


Make your xlim values narrower, as I showed you!

Alternatively, you could also us the "boxwex" parameter passed to
bxp() like this:

boxplot(RF,Ranger, SVM, KNN, DT, range = 0,  col=colors,
        at = seq(1:5), boxwex = .5,
        names= c("RF","Ranger", "SVM", "KNN", "DT"),main="Degree of consistency
with default and optimized settings")

-- Bert

On Sun, Jul 17, 2022 at 1:33 PM Neha gupta <neha.bologna90 using gmail.com> wrote:
>
> Thank you so much.
>
> When I modify this, like the following
>
> xlim = c(.2,4.2),
>
> The spaces between boxplots are reduced but the main box (the container) remains the same which still takes space. Can I reduce the size of the main box (which contains all the boxplots) to take less space.
>
>
>
> On Sun, Jul 17, 2022 at 10:25 PM Bert Gunter <bgunter.4567 using gmail.com> wrote:
>>
>> 1. Typo: should be "KNN = (your data)"  -- not "knn"
>>
>> You specified at.x, but failed to use it.  You need to specify the
>> "at" parameter of boxplot() and probably also "xlim" (which is passed
>> down to bxp(), the function that actually draws the plot).
>>
>> e.g.
>>
>> boxplot(RF,Ranger, SVM, KNN, DT, range = 0, boxwex = 0.2, col=colors,
>> at = seq(1,3,by = .5), xlim = c(.8,3.2),
>>         names= c("RF","Ranger", "SVM", "KNN", "DT"),main="Degree of consistency
>> with default and optimized settings")
>>
>> Modify to your taste.
>>
>> Cheers,
>> Bert
>>
>> On Sun, Jul 17, 2022 at 12:06 PM Neha gupta <neha.bologna90 using gmail.com> wrote:
>> >
>> > Hi
>> >
>> > I have the following code to display boxplots. The problem is it has a wide
>> > space (gap) between them which takes a lot of space on paper. How can I
>> > reduce the size so that it takes less time in a word document.
>> >
>> > RF= c(81.8, 81.8, 42.8, 42.8, 100, 53.8)
>> > Ranger= c(66.6, 81.8, 81.8, 33.3, 81.8, 53.8)
>> > SVM= c(81.8, 66.6, 81.8, 53.8, 81.8, 66.6 )
>> > knn= c(17.64, 33.33, 42.8, 25, 53.84, 17.64)
>> > DT= c(33.3 , 66.6, 33.3, 66.6, 33.3, 25)
>> >
>> >
>> > colors = rep("green",6)
>> > at.x <- seq(1,by=.4, length.out = 10)
>> > boxplot(RF,Ranger, SVM, KNN, DT, range = 0, boxwex = 0.2, col=colors,
>> > names= c("RF","Ranger", "SVM", "KNN", "DT"),main="Degree of consistency
>> > with default and optimized settings")
>> >
>> >         [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > 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.



More information about the R-help mailing list