Marina
Marina

Reputation: 143

Legend filled.contour plot

I am trying to create a contour plot with filled.contour and I would like to change the size of the legend title and labels as well as the size of the legend itself. I have already the code for my data which is very similar to the volcano example (easier to replicate).

data(volcano)
filled.contour(volcano, color = terrain.colors, asp = 1)# simple

x <- 10*1:nrow(volcano)
y <- 10*1:ncol(volcano)
filled.contour(x, y, volcano, color = terrain.colors,
               plot.title = title(main = "The Topography of Maunga Whau",
                                  xlab = "Meters North", ylab = "Meters West"),
               plot.axes = { axis(1, seq(100, 800, by = 100))
                 axis(2, seq(100, 600, by = 100)) },
               key.title = title(main="Height\n(meters)"),
               key.axes = axis(4, seq(90, 190, by = 10),asp=1))# maybe also asp=1

I have tried to add cex and pch parameters but it seems not work.

key.title = title(main="Height\n(meters)",cex=0.5,pch = 1)

Suggestions would be greatly appreciated.

Thank you.

Upvotes: 4

Views: 3770

Answers (1)

Martin Schmelzer
Martin Schmelzer

Reputation: 23899

Use par(cex.main) inside plot.title and key.title:

filled.contour(x, y, volcano, color = terrain.colors,
               plot.title = {par(cex.main=1);title(main = "The Topography of Maunga Whau",
                                  xlab = "Meters North", ylab = "Meters West")},
               plot.axes = { axis(1, seq(100, 800, by = 100))
                 axis(2, seq(100, 600, by = 100)) },
               key.title = {par(cex.main=0.3);title(main="Height\n(meters)")},
               key.axes = axis(4, seq(90, 190, by = 10),asp=1))# maybe also asp=1

enter image description here

Upvotes: 4

Related Questions