문제

I am trying to get data from two separate dataframes onto the same scatterplot. I have seen solutions in R that use something like:

ggplot() + geom_point(data = df1, aes(df1.x,df2.y)) + geom_point(data = df2,aes(df2.x, df2.y))

But in python, with the ggplot module, I get errors when I try to use ggplot() with no args. Is this just a limitation of the module? I know I can likely use another tool to do the plotting but I would prefer a ggplot solution if possible.

My first data frame consists of Voltage information every 2 minutes and temperature information every one hour, so combining the two dataframes is not 1 to 1. Also, I would prefer to stick with Python because the rest of my solution is in python.

도움이 되었습니까?

해결책

Just giving one dataframe as argument for ggplot() and the other inside the second geom_point declaration should do the work:

ggplot(aes(x='x', y='y'), data=df1) + geom_point() + 
       geom_point(aes(x='x', y='y'), data=df2)

(I prefer using the column name notation, I think is more elegant, but this is just a personal preference)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top