Controling the presentation of violin plot

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Controling the presentation of violin plot

Mahmood Naderan-Tahan
Hi,

With the following command, I get a messy violin plot which can be seen at https://pasteboard.co/JVdZKNz.jpg


p <- ggplot(mydata, aes(x=BE, y=INT)) + geom_violin(trim=FALSE)
p + geom_dotplot(binaxis='y', stackdir='center', dotsize=1)


It seems that the y-axis has a large scale and that causes the points to be shown with bad sizes.

Any way to fix that?



Regards,
Mahmood

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Controling the presentation of violin plot

Jim Lemon-4
Hi Mahmood,
As I don't know what "mydata" is, I'll have to fake it. Do you want
something like this?

yourdata<-data.frame(x1=c(1250,600,rep(200,9)),
 x2=c(7000,2300,800,rep(100,8)),
 x3=c(8900,950,300,rep(0,8)),
 x4=c(1400,1000,rep(600,4),rep(200,5)))
library(plotrix)
violin_plot(yourdata)

Jim

On Thu, Apr 1, 2021 at 9:53 AM Mahmood Naderan-Tahan
<[hidden email]> wrote:

>
> Hi,
>
> With the following command, I get a messy violin plot which can be seen at https://pasteboard.co/JVdZKNz.jpg
>
>
> p <- ggplot(mydata, aes(x=BE, y=INT)) + geom_violin(trim=FALSE)
> p + geom_dotplot(binaxis='y', stackdir='center', dotsize=1)
>
>
> It seems that the y-axis has a large scale and that causes the points to be shown with bad sizes.
>
> Any way to fix that?
>
>
>
> Regards,
> Mahmood
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Controling the presentation of violin plot

Rui Barradas
In reply to this post by Mahmood Naderan-Tahan
Hello,

If the problem is the dots sizes, why not reduce it?
Below I have dotsize=0.5, half of yours.


p + geom_dotplot(binaxis='y', stackdir='center', dotsize=0.5)


Alternatively, plot the y axis in a log scale. Since there are zeros in
the data, scales::pseudo_log_trans, will be used.

p + geom_dotplot(binaxis='y', stackdir='center', dotsize=1) +
   scale_y_continuous(
     trans = scales::pseudo_log_trans(base = exp(1))
   )


Hope this helps,

Rui Barradas

Às 23:49 de 31/03/21, Mahmood Naderan-Tahan escreveu:

> Hi,
>
> With the following command, I get a messy violin plot which can be seen at https://pasteboard.co/JVdZKNz.jpg
>
>
> p <- ggplot(mydata, aes(x=BE, y=INT)) + geom_violin(trim=FALSE)
> p + geom_dotplot(binaxis='y', stackdir='center', dotsize=1)
>
>
> It seems that the y-axis has a large scale and that causes the points to be shown with bad sizes.
>
> Any way to fix that?
>
>
>
> Regards,
> Mahmood
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Controling the presentation of violin plot

Mahmood Naderan-Tahan
>Alternatively, plot the y axis in a log scale. Since there are zeros in
>the data, scales::pseudo_log_trans, will be used.
>
>p + geom_dotplot(binaxis='y', stackdir='center', dotsize=1) +
>   scale_y_continuous(
>     trans = scales::pseudo_log_trans(base = exp(1))
>   )



Yes that is a good hint. Thanks.


Regards,
Mahmood

________________________________
From: Rui Barradas <[hidden email]>
Sent: Thursday, April 1, 2021 5:09:20 AM
To: Mahmood Naderan-Tahan; [hidden email]
Subject: Re: [R] Controling the presentation of violin plot

Hello,

If the problem is the dots sizes, why not reduce it?
Below I have dotsize=0.5, half of yours.


p + geom_dotplot(binaxis='y', stackdir='center', dotsize=0.5)


Alternatively, plot the y axis in a log scale. Since there are zeros in
the data, scales::pseudo_log_trans, will be used.

p + geom_dotplot(binaxis='y', stackdir='center', dotsize=1) +
   scale_y_continuous(
     trans = scales::pseudo_log_trans(base = exp(1))
   )


Hope this helps,

Rui Barradas

�s 23:49 de 31/03/21, Mahmood Naderan-Tahan escreveu:

> Hi,
>
> With the following command, I get a messy violin plot which can be seen at https://pasteboard.co/JVdZKNz.jpg
>
>
> p <- ggplot(mydata, aes(x=BE, y=INT)) + geom_violin(trim=FALSE)
> p + geom_dotplot(binaxis='y', stackdir='center', dotsize=1)
>
>
> It seems that the y-axis has a large scale and that causes the points to be shown with bad sizes.
>
> Any way to fix that?
>
>
>
> Regards,
> Mahmood
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>
        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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.