Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I show all boxplot labels

Tags:

r

boxplot

I've created a box plot, the data on the left is the continous variable and the data on the right has about 10 unique options. When I create the boxplot I cannot see the labels. How do I make it show all the labels, possibly vertically?

boxplot(data$Rate ~ as.factor(data$Purpose))

I've looked around and cannot work out what im trying to follow.

like image 941
user1605665 Avatar asked Feb 14 '13 10:02

user1605665


People also ask

How do you show labels on a box plot?

The common way to put labels on the axes of a plot is by using the arguments xlab and ylab.

How do you change the axis labels on a Boxplot in R?

Changing axis labels To alter the labels on the axis, add the code +labs(y= "y axis name", x = "x axis name") to your line of basic ggplot code.

How do you format a Boxplot?

Boxplots can be created for individual variables or for variables by group. The format is boxplot(x, data=), where x is a formula and data= denotes the data frame providing the data. An example of a formula is y~group where a separate boxplot for numeric variable y is generated for each value of group.

How do you label a Boxplot in Python?

from pylab import * import numpy as np fig = figure(figsize=(4,4)) # define the figure window ax = fig. add_subplot(111) # define the axis ax. boxplot(raw_data,1) # make your boxplot # add axis texts ax. set_xlabel('X-label', fontsize=8) ax.


1 Answers

You can add argument las=2 to function boxplot() to make all labels perpendicular to axis.

df<-data.frame(Rate=rnorm(100),Purpose=rep(letters[1:10],each=10))
boxplot(df$Rate~df$Purpose,las=2)

If your label names are long then you should adjust also plot margins.

par(mar=c(7,5,1,1))
boxplot(df$Rate~df$Purpose,las=2)
like image 71
Didzis Elferts Avatar answered Sep 30 '22 20:09

Didzis Elferts