2
我在R中使用ggtern包來繪製三元圖。我無法自定義「填充」的圖例。這裏是我的代碼:三元圖如何使十進制代替科學計數法制作圖例標籤
library(ggtern)
setwd("~/R/data")
library(XLConnect)
df <- readWorksheetFromFile("ternary_two_wells.xlsx",sheet=1,startRow = 1, endCol=7)
# Feldspar = Feldspar[with(Feldspar, order(-P.Gpa)), ]
df = df[with(df,order(-ReTOC)), ]
# Build and Render the Plot
ggtern(data = df, aes(x = Silicate, y = Carbonate, z = Clay)) +
#the layer
geom_point(aes(fill = Permeability,
size = ReTOC,
shape = Well)) +
#scales
scale_shape_manual(values = c(21, 24)) +
scale_size_continuous(range = c(2.5, 7.5)) +
scale_fill_gradient(low = 'green', high = 'red') +
#theme tweaks
theme_bw() +
theme(legend.position = c(0, 1),
legend.justification = c(0, 1),
legend.box.just = 'left') +
#tweak guides
guides(shape= guide_legend(order =1,
override.aes=list(size=5)),
size = guide_legend(order =2),
fill = guide_colourbar(order=3)) +
#labels and title
labs(size = 'ReTOC/%BV',
fill = 'Permeability/nD') +
ggtitle('Two Encana Wells')
下面是導致三元相圖的樣子: 見「滲透性/ ND」傳奇?這是科學記數法。我如何讓它顯示十進制值而不是?
一種選擇是在scale_fill_gradient中使用包標度和'labels =逗號'。見[這裏](http://stackoverflow.com/questions/14563989/force-r-to-stop-plotting-abbreviated-axis-labels-eg-1e00-in-ggplot2)和[here](http://例如:stackoverflow.com/questions/11610377/how-do-i-change-the-formatting-of-numbers-on-an-axis-with-ggplot)。 – aosmith
謝謝。這工作。我如何接受你的回答?它顯示爲一條評論!這裏沒有驗收按鈕或複選標記:) – Bharat