-2

I have a trellis object generated by a 3rd-party package. With that being said, I cannot change the attributes by re-creating another trellis object. I have to change its attributes after it has been created.

I have figured out which attributes control the axes' label font sizes, they are: my_trellis$x.scales$cex[1] and my_trellis$y.scales$cex[1]

But what about the axes' title font sizes? It took me some searches and still could not figure it out...

Thanks!

Matthew Hui
  • 634
  • 5
  • 18
  • 1
    When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Aug 31 '18 at 04:47
  • 1
    One possible guess: if you wanted to make all text/labels bigger, try `my_trellis$par.settings=list(fontsize=list(text=22))` – MrFlick Aug 31 '18 at 04:50
  • @MrFlick Your suggestion can be a workaround, thank you! But it changes both text and label at the same time... Just then I was trying to `dput` my `trellis` for your investigation but when re-run it returns the error `'...' used in an incorrect context` and I can yet figure out how... – Matthew Hui Aug 31 '18 at 05:02

1 Answers1

0

You can change trellis object of lattice package by using trellis.par.get and trellis.par.set function as below:

library(lattice)
# simulation
data("quakes")
Depth <- equal.count(quakes$depth, number=8, overlap=.1)
trellis <- xyplot(lat ~ long | Depth, data = quakes, main = "Large Font Title")


# change title font size
mt = trellis.par.get("par.main.text")
mt$cex = 2
trellis.par.set("par.main.text",mt)
trellis
class(trellis)

Output: library

Artem
  • 3,304
  • 3
  • 18
  • 41