简体   繁体   中英

How to plot a column from one table on x-axis and a column with same name from another table on y-axis

How to plot a column from one table on x-axis and a column with same name from another table on y-axis? I can get the result that I want with this line of code:

countryT_stateT <- plot(Country$T, State$T)

but I'm curious how to do it in tidyverse. So I tried this code but I've got the error "geom_point requires the following missing aesthetics: y"

countryT_stateT <- ggplot()+
  geom_point(data=country, aes(x=T))+
  geom_point(data=state, aes(y=T))+
  labs(title = "Temperatury Country vs. State", subtitle = "2010-2020", 
       x = "Country T", y = "State T")+ 
  theme_classic()+
  theme(
    plot.title = element_text(hjust = 0.5),
    plot.subtitle = element_text(hjust = 0.5)
  )
countryT_stateT

Thanks!

How to plot a column from one table on x-axis and a column with same name from another table on y-axis? I can get the result that I want with this line of code:

countryT_stateT <- plot(Country$T, State$T)

but I'm curious how to do it in tidyverse. So I tried this code but I've got the error "geom_point requires the following missing aesthetics: y"

countryT_stateT <- ggplot()+
  geom_point(data=country, aes(x=T))+
  geom_point(data=state, aes(y=T))+
  labs(title = "Temperatury Country vs. State", subtitle = "2010-2020", 
       x = "Country T", y = "State T")+ 
  theme_classic()+
  theme(
    plot.title = element_text(hjust = 0.5),
    plot.subtitle = element_text(hjust = 0.5)
  )
countryT_stateT

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM