Removing the frame line from the geom_violin() function in R [closed] - r

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Does anyone know how I can remove the curved frame line and only leave the dots in the violin plot when using geom_violin function? As shown in the graph below

first I think that doesn't make sense you remove the shape because it is really helpfull to visualize the distribution of the variable.
But, if you really want it, you have to use geom_dotplot() insted of geom_violin().
Your code could be like this:
ggplot(mtcars, aes(factor(vs), drat)) +
geom_dotplot(binaxis ="y", stackdir = "center")
Then, your result is gonna be:

Related

How to plot 3D data aesthetically? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 months ago.
Improve this question
I have 3 dimensional data and need to plot this data in two ways.
The first one should look like this:
And the second one like this:
where the given data is more like the second plot.
I do know that both plots have completely different styles and therefore it seems not likely to create it in the same way. Right now I am working with R and Im familiar with packages like ggplot2, plotly or rayshader. But I'm not very familiar with creating more aesthetic and less scientific plots like displayed above. Especially the second one seems beyond the capabilities of R.
I would be very grateful if you could give me tips on how to plot 3-dimensional data in this way. Not necessarily by using R.
Thanks!
The second plot type is straightforward in base R:
par(bg = 'black')
par(mar = c(0, 0, 0, 0))
persp(volcano, box = FALSE, col = 'black', border = 'gray90',
theta = 45)

How can tune the plot colors, labels, etc. to make it beautiful? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
What's the meaning of beautiful chart for humans and which theme or color gradients should use, so everybody could say, visually beautiful color and harmony used for the specific chart. Especially, I want to tune colors, labels, etc. in R histogram to gain full mark in my homework. Any help would be appreciated.
You can use this code to have a beautiful histogram
col <- c("#B2182B", "#D6604D", "#F4A582" ,"#FDDBC7", "#D1E5F0", "#92C5DE", "#4393C3" ,"#2166AC")
hist(precip,breaks = 13,col=cm.colors(5),freq =F,xlab = "xlab",ylab = "ylab",main = "main")
your output be something like this :
or this one to have more colorful plot
hist(precip,breaks = 13,col=rainbow(13),freq =F,xlab = "xlab",ylab = "ylab",main = "main")
your output be something like this :
for more details about the attribute of hist function you can look at this link:
https://www.rdocumentation.org/packages/graphics/versions/3.5.3/topics/hist

Superimpose variables within a single pie chart [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to create a pie chart superimposing multiple variables using r-plotly.
For instance, I have values for the global population of a country, it's economically active population, and the economically active male/female.
I want to get all those data inside a single pie chart, with the full cercle as the golbal population, a part of this cercle representing the active population, which is divided itslef in 2 parts, male/female.
I unfortunnatly have no idea how to archieve it and I don't even know is it's possible.
I didn't manage to do it using the function :
plot_ly(...)
Thank you for your help and happy new year !
I think a "sunburst" plot could be what you are looking for.
Here is an example on a fake dataset:
library(sunburstR)
dat <- data.frame(G = c("male-active", "male-inactive", "female-active", "female-inactive"),
N = c(100, 100, 100, 100))
sunburst(dat)

adding density on axes in ggplot2 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I was doing some pretty plots with these density bars on the axes,
but since there I've lost the code and the ability to reproduce the bars.
It would be wonderful if someone could point me to the right command
Thanks
I believe you're looking for geom_rug; here is an example:
ggplot(mtcars, aes(wt, mpg, colour = as.factor(am))) + geom_point() + geom_rug()

How to position the plot legend outside the plot in the bottom-right [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm using the latest ggplot2 and currently do p + theme(legend.position='right'). The function theme is well documented and combining bottom and right doesn't seem possible. However, maybe there is an alternate way to achieve this?
You can use 2-element numeric vector for the position, something like:
p+theme(legend.position=c(0.85,0)
The problem is, it will overlap the plotting area.
And if you want to force it to be in one horizontal line, you can add:
p+guides(fill = guide_legend(nrow = 1))
EDIT
I used plot.margin to expand the area at the bottom, you can play with the parameters:
p+
guides(fill = guide_legend(nrow = 1))+
theme(plot.margin=unit(c(1,1,4,0.5),"cm"))+
theme(legend.position=c(0.85,-0.7))
OR
p+
theme(plot.margin=unit(c(1,1,4,0.5),"cm")) +
theme(legend.position=c(0.85,-0.7))
NOTE
Using Rstudio, when I export the image at certain width*height I don't get the legends, but if I drag and adjust the view before exporting as follows, it works.

Resources