Manually defining the colours of a wireframe
3068 просмотра
1 ответ
I am plotting some surfaces in R using the lattice package. I can't find a way to choose the colours of the surface. Here is an example:
Here is an example of how i plot each:
theseCol=heat.colors(150)
mm=paste("WB numbers where present\n(",nstoch," sims)",sep="")
WBnumbers=wbPrev_series
rownames(WBnumbers)=KList
colnames(WBnumbers)=iMwbList
wireframe(WBnumbers, zlim=c(0,max(wbPrev_series,na.rm=TRUE)), colorkey=FALSE,
col.regions=theseCol, scales = list(arrows = FALSE), drape = TRUE,
main=mm, zlab="", xlab="K", ylab="iMwb")
I would like for the first surface to be as it is, but for the others to be coloured not by their z levels but by the 1st surface's z levels. I tried multiple things but wireframe always accepts the colours i give as the possible ranges for the current variable.
Anyway this could be done? Thanks
Автор: lourencoj Источник Размещён: 13.11.2019 11:32Ответы (1)
2 плюса
Here is the answer Dave W. posted some years back on the R-help mailing list. You probably can google up the entire thread.
From: David Winsemius
Following the advice in help(wirefrane) you need to look at the
levelplot section for advice re: a proper specification to colorkey
and follow the appropriate links in the help pages. Whether your data
is a proper input to wireframe cannot be determined from the included
information, although I suppose your reported success suggests it is.
This is an untested (since there was nothing to test) wild-assed guess
after reading the material I pointed to:
wireframe(data.m,aspect = c(0.3), shade=TRUE, screen = list(z = 0, x =
-45),
light.source = c(0,0,10), distance =
0.2,zlab="Freq",xlab="base",ylab="Fragment",
col=level.colors(x, at = do.breaks(range(data.m), 30),
col.regions = colorRampPalette(c("red", "white",
"blue")(30))
)
EDIT: Per Josh's request, I played around a bit. The following will apply color shading (drape):
wireframe(dmat,drape=TRUE,col='black',col.regions = colorRampPalette(c("red", "white", "blue"))(30) )
Which sets the "drape" colors but not the gridlines themselves.
It's a darn shame that wireframe
doesn't respect par(new=TRUE)
, because if it did we could slice the data matrix into z-ranges and overplot one color at a time.
I will have to check my "archive" of old experiments w/ R graphics when I get home, but I think I ended up using the scatterplot3d
package to get data-dependent grid colors.
Вопросы из категории :
- r Как получить доступ к последнему значению в векторе?
- r Пакеты оптимизации для R
- r Есть ли у R такие операторские операции, как Perl qw ()?
- r Библиотека / инструмент для рисования тройных / треугольных графиков
- r Участки без заголовков / надписей в R
- r Расчет скользящей средней
- r Режим Emacs ESS - вкладка для области комментариев
- r Преобразование данных из многих строк во многие столбцы
- r Проверить, содержит ли вектор данный элемент
- r Поиск всех позиций для нескольких элементов в векторе
- lattice Как нарисовать диаграмму с отсортированными горизонтальными барами ошибок (отсортированные столбцы с метками ошибок)?
- lattice Добавление штриховки в графический / контурный график
- lattice Manually defining the colours of a wireframe
- lattice Решетка строит для цикла - пустые изображения созданы
- lattice Как добавить boxplots на scatterplot с джиттером
- lattice Решетка в R: нижняя часть гистограммы не выровнена по x = 0
- lattice Постройте несколько строк, используя xyplot из решетки
- lattice Автосохранение нескольких страниц решетчатых графиков
- lattice Изменение ограничений по оси X для стратиграфических графиков (т.е. многопанельных графиков)
- lattice Как установить тему по умолчанию для spplot?