2017-02-17 44 views

回答

1

請詳細說明您需要什麼,我假設您只需要給定數據的點。 另外,當您發佈示例數據時,請將其張貼在文本中而不是圖片中,以便我們可以複製它。

使用ggplot2庫進行精彩的繪圖。我用tidyverse而不是數據框使用了一個Tibble,但是你也可以使用它。

# Make your data frame but different months 
data.cars <- tibble(Cars = c("Toyota", "Honda", "Nissan"), Month = c("Jan", 
"Feb", "Mar"), `Distance(km)` = c(124,221,154), `Time(min)`= c(21,34,23)) 

# Make the Months column a factor instead of strings (Jan=1, Feb=2, etc) 
data.cars$Month <- as.factor(data.cars$Month) 

# Make a plot with a common x-axis - the month and different y-axes 
ggplot(data.cars, aes(x = Month)) + 
    geom_point(aes(y = `Distance(km)`, color = "blue")) + 
    geom_point(aes(y = `Time(min)`, color = "red")) 
+0

謝謝你的精彩建議!它有很多幫助。 – Mucho

相關問題