Question

I am using igraph and I want to plot the degree distribution of a graph. Here is an example:

full <- graph.full(20, directed=FALSE)
full_deg = degree.distribution(full)
barplot(full_deg, main='Full graph', xlab='Degree')

I get this picture, but the numbers from the x axis are missing.

r plot

Was it helpful?

Solution

Answer's in the barplot documentation (?barplot). Just add names.arg = 1:20 to your barplot. You can decrease cex.names slightly to allow all items to be displayed.

barplot(abs(rnorm(20)), names.arg=1:20, xlab='Degree', cex.names=0.8)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top