2016-09-13 14 views
0

私は、次のスタイルで、フェードバックの背景を持つグラフを探しています。具体的には、私はすでにようにグラフを作ったggplotグラフの背景色の対角線グレーディングR

Desired graph

対角フェージングを得ることを期待:

ggplot(Data) + 
    aes(x=Data$log.avg, y=Data$CoV) + 
    geom_point(alpha = 0.3) + 
    ggtitle("Oversigt over udbetalingskonti") + 
    geom_text(aes(label=ifelse(Data$log.avg > 1.6 | Data$CoV > 2 & 
    Data$log.avg > -0.5 , as.character(Data$KT),'')),hjust=-0.2, vjust=-0.2, size=3) + 
labs(x="Avg",y="Coefficient of Variation") 
+0

可能な二重にhigh & low引数へのスイッチとコンボで使用しますカラーグラデーション](http://stackoverflow.com/questions/30136725/ggplot2-plot-backgラウンドカラーグラデーション) – loki

+0

すでに見ました。しかし、私は斜めの勾配が必要です。それに応じて投稿を編集します。 – pApaAPPApapapa

+2

[データインク比率](https://en.wikipedia.org/wiki/Chartjunk)がトイレを下ります。 – zx8754

答えて

1

This basic approach同様の問題で私を助けました。

## create a diag gradient background 
## create a df to supply the background to geom_tile 
df <- expand.grid(x=-100:100, y=-100:100)  # dataframe for all combinations 

## plot 
ggplot(df, aes(x, y, fill=x+y)) +  # map fill to the sum of x & y 
    geom_tile(alpha = 0.75) +  # let the grid show through a bit 
    scale_fill_gradient(low='light blue', high='steelblue4')  # choose your colors 

結果:enter image description here

は、次の点を考慮してください

`aes(x, y, fill=x+y)` # darkest in the top right corner 
`aes(x, y, fill=y-x)` # darkest in the top left corner 

[ggplot2プロットの背景のscale_fill_gradient