Order the stacked barplot by proportion or percent in R

I can order my plot based on count but not by proportion. I want to bars on x-axis to be arranged by proportion of "c". Here is my code long<- data.frame( Name = c("abc","abc","abc","gif","gif","gif","xyz","xyz","xyz"), variable = c("a","b","c","a","b","c","c","b","a"), value = c(4,6,NA,2,8,1,6,NA,NA)) long_totals <- long %>% group_by(Name) %>% summarise(Total = sum(value, na.rm = T)) p<-long %>% mutate(variable… Read More Order the stacked barplot by proportion or percent in R

Adding a suffix that includes superscript text to axis text in ggplot

I want to have my x-axis show the scale with an added "m2" at the end of each axis text using the scales::label_number() function. Reproducible code: tibble(x = 1:10, y = 1:10) |> ggplot(aes(x, y)) + scale_x_continuous(label = scales::label_number(suffix = "m^2")) which gives me "5m^2" (for example) on the x-axis, whereas I want it to… Read More Adding a suffix that includes superscript text to axis text in ggplot

How to use `label_date_short`?

How I am using wrongly label_date_short from scales package? library(tidyverse) library(scales) date_taille <- tibble( Taille = rep(c("taille_hiver", "taille_ete"), times = 2), Date_taille = c("2016-08-01", "2016-02-01", "2018-08-01", "2018-02-01") %>% as.Date() ) ggplot(date_taille) + aes(x = Date_taille, y = Taille) + geom_point() + scale_x_date(date_breaks = "month", date_labels = label_date_short()) #or label_date() #> Error in format(x, format =… Read More How to use `label_date_short`?

Plot zeros in a different colour to colour scale in ggplot2

I have a data frame, df: df <- structure(list(animal = c("cat", "cat", "cat", "cat", "cat", "cat", "cat", "cat", "cat", "cat", "cat", "cat", "cat", "cat", "cat", "cat", "cat", "cat"), id = c("201", "202", "203", "204", "215", "217", "201", "202", "203", "204", "215", "217", "201", "202", "203", "204", "215", "217"), tissue = c("tail", "tail", "tail", "tail", "tail",… Read More Plot zeros in a different colour to colour scale in ggplot2

Formatting changes affect only legend and not bar graph using swimplot and ggplot2 packages

Update- this issue was solved, updated code is at the end of the post. I am trying to create a swimmer plot to visualize individual patient duration of treatment with a drug administered at multiple dose levels (DLs). Each patient will be be assigned to treatment with only one DL, but multiple patients can be… Read More Formatting changes affect only legend and not bar graph using swimplot and ggplot2 packages

ggplot – how to set the color of lines using qplot without mapping colors to a variable?

let’s say that I have a very simple piece of code like this: qplot(1:5, 1:5, geom = "line", color = "blue") Unfortunately, this code will not produce a blue line, but, instead, it will try to create mapping for the color and thus you will see that the legend has appeared on the right side… Read More ggplot – how to set the color of lines using qplot without mapping colors to a variable?