Barplots - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Barplots (/thread-13205.html) |
Barplots - Jack2 - Oct-03-2018 I'm trying to create horizontal and vertical bar plots. Below is my code. However, pressing "return" after the first plot command (line 3 of the code), all I get is the first output listed below. And after pressing "return" after the second plot command (line 4 of the code), I get the second output listed below. I do not get a graphical bar plot. I have imported everything I can think of: numpy, matplotlib.pyplot, pandas (i.e. things that I need to plot the graph as well as things I don't need) but horizonal and vertical bar plots are NOT being produced. Could someone help? I'm a complete newbie. fig, axes = plt.subplots(2,1) data = pd.Series(np.random.rand(16), index=list('abcdefghijklmnop')) data.plot.bar(ax=axes[0], color='k', alpha=0.7) data.plot.barh(ax=axes[1], color='k', alpha=0.7)Output received: <matplotlib.axes._subplots.AxesSubplot at 0x2016a51ad30> <matplotlib.axes._subplots.AxesSubplot at 0x2016a54e438> RE: Barplots - Mekire - Oct-04-2018 Call plt.show() and it seems to give what you want:import numpy as np import pandas as pd from matplotlib import pyplot as plt ig, axes = plt.subplots(2,1) data = pd.Series(np.random.rand(16), index=list('abcdefghijklmnop')) data.plot.bar(ax=axes[0], color='k', alpha=0.7) data.plot.barh(ax=axes[1], color='k', alpha=0.7) plt.show()[attachment=479] |