Removing "Class" from visualization

Dear All,

Would you please let me know how to remove this "class" from the output figure? this is what I am using to generate the plot.

install.packages("readxl")

library("readxl")
library(ggplot2)
library(tidyverse)
library(dplyr)

tmp_table <- read.csv(text="
class_set_val

2_12_49319
2_13_98443

3_123_18191
3_124_8405

4_1234_2807
4_1235_2871

5_12345_425
5_12346_310

6_123456_50
6_123457_55

")

df <- (tmp_table %>% separate(class_set_val,c("class","set","val"),sep="([_])")
)
df$class <- factor(df$class,
levels = c("2","3","4","5","6","7"),
labels = c("2-fold","3-fold","4-fold","5-fold","6-fold","7-fold") )
df$val <- as.numeric(df$val)
df$log_val <- log10(df$val)

plotting on normal scale

p0 <- (ggplot(df, aes(x=set,y=val,col=class))
+ geom_point(aes(colour = factor(class)), size = 6)
##+ geom_smooth(se = FALSE, method = lm) ## trend in each class
+ facet_wrap(~ class)
+ facet_grid(~ class , scales="free")
)
print(p0)

p1 <- (ggplot(df, aes(x=set,y=log_val,col=class))
+ geom_point(aes(colour = factor(class)), size = 4)
+ xlab("CP")
+ ylab("CC")
##+ geom_smooth(se = FALSE, method = lm) ## trend in each class
+ facet_wrap(~ class)
+ facet_grid(~ class , scales="free")
)
print(p1)

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

1 Like

Hello, many thanks! I did.

Can you clarify what you mean by "remove this class from the output figure"? Do you mean removing the legend like in this example?

library(tidyverse)

df <- data.frame(
  stringsAsFactors = FALSE,
               set = c("12","13","123","124",
                       "1234","1235","12345","12346","123456","123457"),
               val = c(49319, 98443, 18191, 8405, 2807, 2871, 425, 310, 50, 55),
           log_val = c(4.69301426218799,
                       4.99318484013431,4.25985657385978,3.92453771777549,3.44824241263444,
                       3.45803319249651,2.62838893005031,2.49136169383427,
                       1.69897000433602,1.74036268949424),
             class = as.factor(c("2-fold",
                                 "2-fold","3-fold","3-fold","4-fold","4-fold",
                                 "5-fold","5-fold","6-fold","6-fold"))
)

ggplot(df, aes(x = set, y = log_val, col = class)) +
    geom_point(aes(colour = class), size = 4, show.legend = FALSE) +
    labs(
        x = "CP",
        y = "CC") +
    facet_grid(~ class , scales="free")

Created on 2021-03-09 by the reprex package (v1.0.0.9002)

1 Like

Yes, exactly. Thank you so much!

Would you please let me know is there any way to makes these labels show correctly? it should appear as g^(n).

df$class <- factor(df$class,
levels = c("2","3","4","5"),
## labels = c("g⁽2⁾","g⁽3⁾","g⁽4⁾","g⁽5⁾")
....

p1 <- (ggplot(df, aes(x=set,y=log_val,col=class, ))
+ geom_point(aes(colour = factor(class)), size = 1,show.legend = FALSE)
+ xlab("Channels permutation")
+ ylab( ~g^n~(0) (Log[10]))
+ theme(text=element_text(family="serif", size=12), axis.text.x = element_text(family="Times",size = 5,angle=270,vjust = 0.2,hjust = 0))
+ scale_x_discrete(labels = make_labels)
+ theme(axis.text = element_text(family="serif"))
+ facet_wrap(~ class)
+ facet_grid(~ class , scales="free")
)
print(p1)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.