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)")

Some discussion on chat indicates
levelplot()handles the heatmap case (where one or both variables are discrete/categorical) just fine. Therefore, we just need to get the data into the correct format. One way to do that is to store at least theycoordinate as a factor with the appropriate levels set.First, simulate some data along the lines of the OP’s data:
which gives:
The reason for the
expand.grid()call is thatlevelplot(), when used via the formula method, which I am about to make use of, needs aYand aXfor each data point (900 of them in this case).The plot is then easy to produce via a simple formula in
levelplot():which produces this: