Skip to content

Commit 51d6f16

Browse files
committed
BUG: MPL Plot cannot make loglog option worked
1 parent 39923f6 commit 51d6f16

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

pandas/tests/test_graphics.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,22 @@ def test_plot_xy(self):
409409
# columns.inferred_type == 'mixed'
410410
# TODO add MultiIndex test
411411

412+
@slow
413+
def test_logscales(self):
414+
df = DataFrame({'a': np.arange(100)},
415+
index=np.arange(100))
416+
ax = df.plot(logy=True)
417+
self.assertEqual(ax.xaxis.get_scale(), 'linear')
418+
self.assertEqual(ax.yaxis.get_scale(), 'log')
419+
420+
ax = df.plot(logx=True)
421+
self.assertEqual(ax.xaxis.get_scale(), 'log')
422+
self.assertEqual(ax.yaxis.get_scale(), 'linear')
423+
424+
ax = df.plot(loglog=True)
425+
self.assertEqual(ax.xaxis.get_scale(), 'log')
426+
self.assertEqual(ax.yaxis.get_scale(), 'log')
427+
412428
@slow
413429
def test_xcompat(self):
414430
import pandas as pd
@@ -1229,6 +1245,7 @@ def test_errorbar_plot(self):
12291245
# check line plots
12301246
_check_plot_works(df.plot, yerr=df_err, logy=True)
12311247
_check_plot_works(df.plot, yerr=df_err, logx=True, logy=True)
1248+
_check_plot_works(df.plot, yerr=df_err, loglog=True)
12321249

12331250
kinds = ['line', 'bar', 'barh']
12341251
for kind in kinds:

pandas/tools/plotting.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -976,9 +976,9 @@ def _setup_subplots(self):
976976

977977
axes = [ax]
978978

979-
if self.logx:
979+
if self.logx or self.loglog:
980980
[a.set_xscale('log') for a in axes]
981-
if self.logy:
981+
if self.logy or self.loglog:
982982
[a.set_yscale('log') for a in axes]
983983

984984
self.fig = fig
@@ -1879,9 +1879,11 @@ def plot_frame(frame=None, x=None, y=None, subplots=False, sharex=True,
18791879
scatter: scatter plot
18801880
hexbin: hexbin plot
18811881
logx : boolean, default False
1882-
For line plots, use log scaling on x axis
1882+
Use log scaling on x axis
18831883
logy : boolean, default False
1884-
For line plots, use log scaling on y axis
1884+
Use log scaling on y axis
1885+
loglog : boolean, default False
1886+
Use log scaling on both x and y axes
18851887
xticks : sequence
18861888
Values to use for the xticks
18871889
yticks : sequence
@@ -2031,9 +2033,11 @@ def plot_series(series, label=None, kind='line', use_index=True, rot=None,
20312033
grid : matplotlib grid
20322034
legend: matplotlib legend
20332035
logx : boolean, default False
2034-
For line plots, use log scaling on x axis
2036+
Use log scaling on x axis
20352037
logy : boolean, default False
2036-
For line plots, use log scaling on y axis
2038+
Use log scaling on y axis
2039+
loglog : boolean, default False
2040+
Use log scaling on both x and y axes
20372041
secondary_y : boolean or sequence of ints, default False
20382042
If True then y-axis will be on the right
20392043
figsize : a tuple (width, height) in inches

0 commit comments

Comments
 (0)