I am trying to create line graph with the following code:
ggplot(lnewdat, aes(x = Cl, y = Probability, colour = Level, group = Level)) + geom_smooth(stat = 'identity') + facet_grid(Species~Year)
I get the a graph that looks similar to this graph:
When looking up a solution to the jagged lines, everything mentions setting the "Group". As you can see from my code, I have already done that. Your help is appreciated!
Related
I am having a hard time plotting percentage instead of count when using facet_grid.
I have the following DF (this is an example, my DF is much longer):
'Gu<-c("1","0","0","0","1","0")
variable<-c("THR","Screw removal","THR","THR","THR","Screw removal")
value<-c("0","1","0","1","0","0")
df2<-data.frame(Gu,variable,value)'
and I am trying to plot the "1" values out of the specific variable (either THR or Screw removal) and split the graph by "Gu" (facet grid).
I manage to code it to plot count, but I can seem to be able to calculate the percentage (I need to calculate the percentage from each variable only and not from all the DF)
This is my code:
ggplot(data = df2, aes(x = variable,y =value ,
fill = variable)) +
geom_bar(stat = "identity")+
facet_grid(~ Gu,labeller=labeller(Gu
=c('0'="Nondisplaced fracture",'1'="Displaced
fracture")))+
scale_fill_discrete(name = "Revision", labels =
c("THR","SCREW"))
and this is what I plotted:
enter image description here
I searched this website and the web and couldn't find an answer...
any help will do!
thanks
and I am trying to create a double layered pie, here is my data:
winner <- c("White" , "draw" , "Black")
lowrated_scotch1 <- c(0.56617647, 0.04411765, 0.38970588) #winrate for Whites,Draws,Blacks in chess
highrated_scotch1 <- c(0.50000000, 0.03676471, 0.46323529)
To give more context, i'm trying to visualize the difference in winrate between whites/draws/blacks for a highrated/lowrated players in Chess for the Scotch opening from the data I already managed to gather.
This is what I have in mind :(image taken from google image)
layered pie chart example.
This is my code :
multi_layer_scotch<-data.frame(winner = c("White","draw","Black"),
Y = c(highrated_scotch),
X = c(lowrated_scotch))
ggplot(multi_layer_scotch, aes(x = X, y = Y, fill = winner))+
geom_bar(stat = "identity")+
scale_fill_manual(values = c("#769656","#baca44","#eeeed2"))+
coord_polar(theta="y")+
theme_void()
and this is what i'm getting as an output :
my marvelous not complete graph
As you can see, the graph isn't layered the way I want. The 3 layers from my plot should be assembled in one layer (to represent the lowrated payers) stacked with another layer (representing the highrated players).
I tried to follow the solution given in this post , but I couldn't manage to do it myself, I felt like it was a little incomplete : Multi-level Pie Chart in R
I'de be glad if you could help me with this! thanks in advance
did you mean something like this:
df1 <- melt(multi_layer_scotch)
ggplot(df1, aes(x = variable, y = value, fill = winner))+
geom_bar(stat = "identity")+
coord_polar(theta="y")
I have a Date column and Value column. I did my research on internet and tried every possible thing but it does not shows my the trend line graph. I am totally confused what is happening in my data. I have shared my code below:
ggplot(data = New, aes(x = OrderDate, y = TotalAmountWithGST))+
geom_line(color = "#00AFBB", size = 2) + scale_x_date(date_labels = "%b/%Y")
ggplot(x, aes(x = OrderDate, y = TotalAmountWithGST)) +
geom_line()+
theme_minimal()
I am trying to plot a line graph that shows a monthly trend but somehow I am getting a graph that is similar to bar graph but its not a line graph.
You need to add a geom_smooth to your ggplot code.
It's hard to replicate a working example without sample data but that should get you on the right path.
I'm new to coding and can't find an answer to my question online. I need to plot a graph with 2 lines with a log scale to bring the 2 data sets closer together. I have worked out the code for the 2 lines but cant make it work with a log scale, please help :)
ggplot(df, aes(x= df$Date)) +
+ geom_line(aes(y = df$SearchVolume, colour = "Search Volume")) +
+ geom_line(aes(y = df$People, colour = "People"))
The y axis needs to become log if that is possible
I have a continous variable that I would like to map to the color of my points.
However the distribution of the variable is shifted tot the right.
So I thought I could use the quantiles to set the breaks but this doesn't seem to be working.
I think I don't understand the subtleties between all of the different variants of scale_colour_gradient.
ggplot(df, aes(x = LibPl, y = IntStd, color = totSmpInt)) +
geom_point(position = "jitter", alpha = 0.5) +
scale_colour_gradientn(colours = brewer.pal(n = 4, "RdYlBu"),
breaks = c(qn[1], qn[2], qn[3], qn[4], qn[5]))
As you can see from the color legend in the plot it doesn't really seem like the quantiles were used as break points.
I have read a few other similar posts, and tried variants, but none are working
Any help is appreciated.
Thanks,