Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change numeric tickmarks to letters on levelplot

Tags:

r

lattice

I'm working on on some details on my plots and I've found one I can't get around. On my levelplot are numeric tickmarks. Now I want my tickmarks on the y-axis to be changed to the corresponding Letters. (i.e. 1=A, 5=E,27=AA, 29=AC,...)

I've already used

scales=list(
    y=list(alternating=3,labels=toupper(c(letters[1],letters[5],letters[10],letters[15])))))

But I want them to change depending on what's on the Y-axis, not from values I'm giving. Can anybody help me on this one?

levelplot(volcano,main="levelplot(volcano)")

enter image description here

like image 698
Sir Ksilem Avatar asked Dec 09 '25 09:12

Sir Ksilem


1 Answers

Not general solution. Use pretty to compute at by self.

y_at <- pretty(seq_len(ncol(volcano)))
y_labels <- c(LETTERS, outer(LETTERS, LETTERS, paste, sep=""))
levelplot(
    volcano, main="levelplot(volcano)",
    scales=list(y=list(
        alternating=3,
        labels=y_labels[round(y_at)],
        at=y_at
    ))
)

Lattice levelplot with change y axis

like image 199
Marek Avatar answered Dec 12 '25 13:12

Marek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!