λ€μ μ½λκ° μλνλ©° Jupyter Notebook λλ QT μ½μμ λΆμ¬ λ£μΌλ©΄ μμλλ λ§λ κ·Έλνκ° μμ±λ©λλ€.
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
# Create some data to plot
df = pd.DataFrame(
dict(Feature1=[10, 20, 30, 20, 10], Feature2=[3, 2, 3, 2, 3]),
index=['a', 'b', 'c', 'd', 'e']
)
_ = df.plot(kind='bar', legend=False, y='Feature1', yerr='Feature2', rot=0)
κ·Έλ¬λ μ¬μ©μ μ§μ Axes
μΈμ€ν΄μ€λ₯Ό μ 곡νλ €κ³ νλ©΄ (κ·ΈλμΌ νλ‘―μ΄ μνλ μμΉμ λ°°μΉλ¨) μ€λ₯κ° λ°μν©λλ€. μμ μμ λ₯Ό μ€ν ν ν λ€μ μ½λλ₯Ό μ€ννλ©΄ μ€λ₯κ° λ°μν©λλ€.
fig = plt.figure(0)
ax = fig.add_subplot(111)
_ = df.plot(kind='bar', legend=False, y='Feature1', yerr='Feature2', rot=0, axes=ax)
λ€μμ μ μΆμ μ λλ€.
Traceback (most recent call last):
File "<stdin>", line 12, in <module>
File "/usr/local/miniconda3/lib/python3.5/site-packages/pandas/tools/plotting.py", line 3740, in __call__
sort_columns=sort_columns, **kwds)
File "/usr/local/miniconda3/lib/python3.5/site-packages/pandas/tools/plotting.py", line 2614, in plot_frame
**kwds)
File "/usr/local/miniconda3/lib/python3.5/site-packages/pandas/tools/plotting.py", line 2441, in _plot
plot_obj.generate()
File "/usr/local/miniconda3/lib/python3.5/site-packages/pandas/tools/plotting.py", line 1028, in generate
self._make_plot()
File "/usr/local/miniconda3/lib/python3.5/site-packages/pandas/tools/plotting.py", line 1971, in _make_plot
log=self.log, **kwds)
File "/usr/local/miniconda3/lib/python3.5/site-packages/pandas/tools/plotting.py", line 1918, in _plot
return ax.bar(x, y, w, bottom=start, log=log, **kwds)
File "/usr/local/miniconda3/lib/python3.5/site-packages/matplotlib/__init__.py", line 1812, in inner
return func(ax, *args, **kwargs)
File "/usr/local/miniconda3/lib/python3.5/site-packages/matplotlib/axes/_axes.py", line 2134, in bar
self.add_patch(r)
File "/usr/local/miniconda3/lib/python3.5/site-packages/matplotlib/axes/_base.py", line 1780, in add_patch
self._set_artist_props(p)
File "/usr/local/miniconda3/lib/python3.5/site-packages/matplotlib/axes/_base.py", line 865, in _set_artist_props
a.axes = self
File "/usr/local/miniconda3/lib/python3.5/site-packages/matplotlib/artist.py", line 237, in axes
raise ValueError("Can not reset the axes. You are "
ValueError: Can not reset the axes. You are probably trying to re-use an artist in more than one Axes which is not supported
λ λ²μ§Έ νλ‘―μ΄μ΄ μμ μ 첫 λ²μ§Έ νλ‘―κ³Ό λμΌνκ² μλ ν κ²μΌλ‘ μμν©λλ€.
pd.show_versions()
μΆλ ₯INSTALLED VERSIONS
------------------
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.6-gentoo
machine: x86_64
processor: Intel(R) Core(TM) i3-3240 CPU @ 3.40GHz
byteorder: little
LC_ALL: None
LANG: en_US.utf8
pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 25.1.6
Cython: None
numpy: 1.11.1
scipy: 0.18.0
statsmodels: 0.6.1
xarray: None
IPython: 5.1.0
sphinx: 1.4.1
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: None
tables: 3.2.3.1
numexpr: 2.6.1
matplotlib: 1.5.1
openpyxl: None
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext)
jinja2: 2.8
boto: None
pandas_datareader: None
(FWIW, λ°©κΈ μ΅μ λ²μ μ pandasλ₯Ό λΉλνκ³ μλνλλ° λμΌν λμμ΄ λ°μνμ΅λλ€.
pandas: 0.18.1+391.g6645b2b
)
axes
ax=ax
μ (λ₯Ό) μ¬μ©νλ €κ³ ν©λλ€.
λΆννλ μ΄λ¬ν μ’
λ₯μ μ€λ₯λ₯Ό μ‘κΈ° μν΄ ν μμλ μΌμ΄ λ§μ§ μλ€κ³ μκ°ν©λλ€. .plot
λ©μλμμ **kwargs
λ₯Ό λ°μ κΈ°λ³Έ matplotlib λ©μλ (μ : .ax.bar
)μ μ λ¬ν©λλ€. μ matplotlib axes.bar
μμ pylab μΈν°νμ΄μ€μμ νΈνμ±μ μν΄ axes
ν€μλλ₯Ό νμ©νλμ§ μ λͺ¨λ₯΄κ² μ΅λλ€.
μ§κΈμμ΄ λΆλΆμ λ«κ² μ΅λλ€. μ°λ¦¬λ μ μ¬μ μΌλ‘ λ°μ λ€μΌ μ axes
μν λ³μΉμΌλ‘ ax
(μ μλμ§ ax
μλ μ νλμλ€),νμ§λ§ μ§κΈμ 보λ₯ λ§μ λ§μ μ¬λλ€μ΄ μ€ννλ κ²½μ° λ³Ό κ² μ΄κ²μΌλ‘.
Ack. κ°μ¬!
κ°μ₯ μ μ©ν λκΈ
axes
ax=ax
μ (λ₯Ό) μ¬μ©νλ €κ³ ν©λλ€.λΆννλ μ΄λ¬ν μ’ λ₯μ μ€λ₯λ₯Ό μ‘κΈ° μν΄ ν μμλ μΌμ΄ λ§μ§ μλ€κ³ μκ°ν©λλ€.
.plot
λ©μλμμ**kwargs
λ₯Ό λ°μ κΈ°λ³Έ matplotlib λ©μλ (μ :.ax.bar
)μ μ λ¬ν©λλ€. μ matplotlibaxes.bar
μμ pylab μΈν°νμ΄μ€μμ νΈνμ±μ μν΄axes
ν€μλλ₯Ό νμ©νλμ§ μ λͺ¨λ₯΄κ² μ΅λλ€.