Expanding the X-axis using R [duplicate] - r

This question already has answers here:
How do I show all boxplot labels
(3 answers)
How to save a plot as image on the disk?
(11 answers)
Closed 2 years ago.
there has some issue with my axis, I want to show the full data at the axis but I am not sure how to expand it. This my code.
boxplot(Complied_Data$`Stress (N/m2)` ~ Complied_Data$Category,
main="Stress Distribution of different rates", ylab="Stress (Pa)",
xlab="Specimens", notch=TRUE, col="brown1", cex=10)

Related

R remove names and order ggplot by frequency [duplicate]

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")

Break or kink // in x axis in ggplot2 [duplicate]

This question already has answers here:
Using ggplot2, can I insert a break in the axis?
(10 answers)
Put a break in the Y-Axis of a histogram
(2 answers)
Closed 2 years ago.
ggplot(data= data,aes=(x=parameter,y= Count,fill=value)) + geom_bar(position="dodge",stat="identity")+ cord_flip()
I want to get break in x-axis like initially, I want scales to be 1,2,3,4,5 then a break followed by 5,10,15. Please refer the below figure for break or kink I am talking about

How to remove value from a plot on R [duplicate]

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.

how to order the boxes in side by side box plots? [duplicate]

This question already has answers here:
Sort boxplot by mean (and not median) in R
(1 answer)
R - ordering in boxplot
(2 answers)
Closed 7 years ago.
I am trying to create a box plot of the Baltimorecity Salaries open data:
> par(mar=c(16,4,1,1))
> boxplot(mydata$GROSSPAY ~ mydata$AGENCY, las=2)
I would like to display the boxes in order of of the total GROSSPAY of the AGENCY.
Is this possible with R? If so, how?
As this question was closed, I'm pasting an answer here:
mydata <- mydata[ ! is.na(mydata$GROSSPAY), ]
mydata$AGENCY <- with(mydata, reorder(AGENCY, GROSSPAY, sum))
par(las=2)
par(mar=c(16,4,1,1))
boxplot(mydata$GROSSPAY ~ mydata$AGENCY)

% in barplot() instead of count [duplicate]

This question already has answers here:
How can I change the Y-axis figures into percentages in a barplot?
(4 answers)
Closed 8 years ago.
I did a script to have a good barplot with barplot() on R
Is it possible to have on the y-axis the % and not the quantity (number of observations) ?
I would love to have the % without to change all of the script...
Thanks a lot
ggplot has this option, but for barplot() I believe you will have to make a new variable that represents the percent and then feed that into barplot()

Resources