I use the code coul = brewer.pal(5, "Set2")
and plot the barplot barplot(data[,1], col=coul)
by columns. However, I actually have more than 200 rows for each column. How can I expand the number of colour? * I use the barplot
function in base R.
Asked
Active
Viewed 63 times
-1

Math Avengers
- 762
- 4
- 15
-
2Hi, you may want to include a [small reproducible example](https://stackoverflow.com/a/5963610/11810235) with more detail to make it easier for people to answer your question. – rpolicastro Jul 17 '20 at 00:44
1 Answers
1
colorRampPalette receives a color vector, later you pass the number of colors you want between those colors.
colorFunc <- colorRampPalette(c('#ff0000', '#ff0000', '#00aaff',...))
colors <- colorFunc(dim(df)[2])
Here I passed the number of columns, so it will return as many colors as columns, if you want as many colors as rows:
colors <- colorFunc(dim(df)[1])

Omar Omeiri
- 1,506
- 1
- 17
- 33