This question already has answers here:
Order Bars in ggplot2 bar graph
(16 answers)
Remove all of x axis labels in ggplot [duplicate]
(1 answer)
Closed 2 years ago.
I have a dataframe DiatomFiltered containing the column species. I want to have a ggplot (ggplot2) of all species and their frequency ordered from highest to lowest. The below code works, but the names are a mess (because of way too many species names) so I want to remove that and i want the frequencies ordered. How do i do this?
ggplot(DiatomFiltered, aes(species)) +
geom_bar(fill = "#0073C2FF")
Related
This question already has answers here:
creating a boxplot for two different column of data frame using ggplot [duplicate]
(2 answers)
Making a ggplot boxplot where each column is it's own boxplot
(2 answers)
Closed 13 days ago.
I have a dataset composed of 10 columns and I want to create a boxplot for each column using ggplot2. They idea is to see if there are outliers in any column
I know how to use to the package to create a boxplot for each column individually but I would like to know if it is possible to make it directly to all columns of the data set
This question already has answers here:
Order Bars in ggplot2 bar graph
(16 answers)
Reorder bars in geom_bar ggplot2 by value
(3 answers)
ggplot2 geom_bar - how to keep order of data.frame [duplicate]
(1 answer)
Closed 1 year ago.
I'm trying to do a barplot where entries of the same factor are next to eachother so I can compare (in this example I want to compare the tissue type).
I sort the dataframe but for some reason ggplot does not follow the sorting.
tp <- ms %>%
arrange(tissue) %>%
mutate(tissue=as.factor(tissue))
ggplot(tp) +
geom_bar(aes(x=Sample, y=!!sym(cv), fill=tissue), stat="identity") +
ylab("")
head(tp$tissue)
and I check and i know that tp is sorted
head(tp$tissue) outputs
[1] adjacent adjacent adjacent adjacent adjacent adjacent
Levels: adjacent normal tumor
This question already has answers here:
How to reorder a legend in ggplot2?
(2 answers)
Reorder levels of a factor without changing order of values
(9 answers)
Closed 5 years ago.
I am making CDF plots using this line of code:
library(ggplot2)
ExpDF <- data.frame(x=c('gene1','gene2','gene3','gene4'),"FC"=c(1,2,3,4))
ts_miR_15 <- data.frame(x=c('gene1','gene3','gene4'),"FC"=c(1,3,4))
ahc_miR_15_3UTR <- data.frame(x=c('gene1','gene4','gene12'),"FC"=c(1,4,12))
g <- ggplot(data = NULL)
g + geom_step(aes(x=ExpDF$FC, color="All_genes"),stat="ecdf") +
geom_step(aes(x= ts_miR_15$FC, color="Targetscan_miR-15/16"), stat="ecdf") +
geom_step(aes(x= ahc_miR_15_3UTR$FC, color="3UTR_miR-15/16_seed"), stat="ecdf") +
scale_colour_manual("Subsets", values = c("All_genes"='black',
"Targetscan_miR-15/16"='orange',
"3UTR_miR-15/16_seed"='red'))
...(etc. for each additional data.frame
I would like to be able to reorder the labels for the legend such that "All_genes" is on top (and preferably have it in any oder I want). I would prefer to keep the data.frames separate because they have different numbers of genes (which mark the rows) in them and some of them are subsets of the other.
This question already has answers here:
Boxplot sees values that aren't there
(1 answer)
How to remove ticks and labels of dropped off factors in a box plot
(1 answer)
Closed 5 years ago.
You can see my plot in this link.
I want to remove the first three points from the x axis, so I only display data from "2.31-52k", "1.52-100k", "3.18-31k", "4.<18k", "0.>100k". And not -1.0,-3.1 etc.
I have managed to remove the data to produce this graph, by creating a subset in dAll$income and assigning it to a new data frame with the following code.
new_df = subset(dAll, subset = dAll$income %in% c("2.31-52k", "1.52-100k", "3.18-31k", "4.<18k", "0.>100k"))
However when I plot this, the values remain on the x axis.
This question already has answers here:
Reorder levels of a factor without changing order of values
(9 answers)
Closed 9 years ago.
I have created a plot of coverage vs gene. I would like to plot the genes (x axis) from lowest coverage value (y axis) to largest. I used the function "plot" but it automatically sorts the gene names from lowest to highest. How do I arrange them from lowest coverage to highest instead?
Maybe switch the ylim:
plot(1:10, ylim=c(10,1))