我通过使用以下条形图:
void QDeclarativePositionSource::setnmeaSource(const QUrl &nmeaSource)
我想将温度值添加为渐变填充的绘图面板,类似于PAR值。因此,例如6月1日的情节面板为浅绿色,6月6日的情节面板为深绿色,其余之间为。数据框中每天有一个温度值。有这样做的可能性吗?
您的问题包含很多代码,但是仍然无法复制。丢人现眼!一般来说,这是一个有趣的问题。 尽管我个人认为“少即是多”,并且应该尽量不要在图表中添加过多信息,但这是一种解决方案。
ggnewscale
。 Voilà!
library(tidyverse)
library(ggnewscale)
mtc <- tibble::rownames_to_column(mtcars,'model')
rect_df <- data.frame(xmin = -Inf,xmax = +Inf,ymin = -Inf,ymax = +Inf,cyl = unique(mtc$cyl))
ggplot() +
geom_rect(data = rect_df,aes(xmin = xmin,xmax = xmax,ymin = ymin,ymax = ymax,fill = cyl)) +
facet_grid(~cyl) +
scale_fill_gradient(low="lightgreen",high = "darkgreen") +
ggnewscale::new_scale_fill() +
geom_col(data = mtc,aes(x = model,y = gear,fill = disp)) +
scale_fill_gradient2(low="darkblue",mid = "orange1",high = "orangered4",limits=c(min(mtc$disp),max(mtc$disp)),midpoint = mean(mtc$disp)) +
coord_flip()
由reprex package(v0.3.0)于2020-01-03创建