A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://stackoverflow.com/questions/18151775/create-yoy-graph-with-matplotlib/18153525 below:

python - Create YoY Graph with Matplotlib

I am using IPython or the Python shell to interact with matplotlib. I have two DataFrames. Each has an index of months in the 'YYYY-MM' format (these are just strings). The rest of the columns are sums of different values.

One DataFrame contains 2012 data, and the other contains 2013 data. Since it is still 2013, there are nulls for many of the 2013 months.

The graph I want to create just uses one metric at a time, and shows 2013 data as bars, and 2012 data as a line. I want both graphs to be laid on top of each other, and share x- and y-axis. I also want the bars to be centered on each data point.

The nulls in the 2013 data seem to be causing issues.

Here is sample of what I have tried in IPython:

df2012['metric'].plot(color='black')
bar(np.arange(len(df2013.index)), df2013['metric'], align='center') 

I have also tried using twinx() and twiny() but also having issues.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4