Stephan Kolassa
Stephan Kolassa

Reputation: 8267

Changing the fontsize of axis annotations in a hexbinplot

I would like to increase the font size of axis annotations in a hexbinplot.

library(hexbin)
df <- data.frame(x=rnorm(1000),y=rnorm(1000))
hb <- hexbin(x=df$x, df$y)
myPlot <- plot(hb, xlab="", ylab="", legend=FALSE)

hexbinplot

I would like the -3, ..., 2 and the -2, ..., 3 on the axes to be larger.

This earlier thread already helped me with axis labels, but the suggestion about how to change the annotations ("use grid.ls()" - how?) is a little too cryptic for me. I am more fluent in base graphics than in lattice.

Upvotes: 0

Views: 138

Answers (1)

dcarlson
dcarlson

Reputation: 11076

Try this.

library(grid)
myPlot <- plot(hb, xlab="", ylab="", legend=FALSE)
grid.ls()
# GRID.rect.250
# GRID.xaxis.251
# GRID.yaxis.252
# GRID.polygon.253
grid.edit("GRID.xaxis.251", gp=gpar(fontsize=20))
grid.edit("GRID.yaxis.252", gp=gpar(fontsize=20))

The grid.ls() function shows the parts of the graph. The axis labels are GRID.xaxis.251 and GRID.yaxis.252. The name labels should be the same but the numbers will be different so you will have to modify the grid.edit() lines to match the output from grid.ls().

Upvotes: 1

Related Questions