简体   繁体   中英

Plot 2 dataframe in one graph

I have 2 dataframe. I am trying to plot the net_revenue from dataframe1 and Adj close from dataframe2. By using date as x-axis. Is there has any solution to do that?

Dataframe 1

    symbol  date    net_revenue
0   ETSY    2014-03-31  40536000
1   ETSY    2014-06-30  42509000
2   ETSY    2014-09-30  47634000
3   ETSY    2014-12-31  64912000
4   ETSY    2015-03-31  58543000
5   ETSY    2015-06-30  61365000
6   ETSY    2015-09-30  65696000
7   ETSY    2015-12-31  87895000
8   ETSY    2016-03-31  81847000

Dataframe 2

            High        Low         Open        Close       Volume  Adj Close
Date                        
2015-04-16  35.740002   28.219999   31.000000   30.000000   19763300    30.000000
2015-04-17  30.299999   26.510000   29.770000   27.580000   3965500 27.580000
2015-04-20  28.900000   24.870001   28.770000   24.900000   3076200 24.900000
2015-04-21  26.040001   24.559999   24.969999   25.750000   2184700 25.750000
2015-04-22  26.240000   24.950001   26.000000   25.120001   1442500 25.120001

Use plt.subplot to create an ax then plot both dfs on that ax.

fig, ax = plt.subplots(figsize=(10,5))

df1.set_index('date')[['net_revenue']].plot(ax=ax)
df2[['Adj Close']].plot(ax=ax)

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