@@ -2658,8 +2658,6 @@ def test_pie_df_nan(self):
2658
2658
2659
2659
@pytest .mark .slow
2660
2660
def test_errorbar_plot (self ):
2661
- import matplotlib .pyplot as plt
2662
-
2663
2661
d = {"x" : np .arange (12 ), "y" : np .arange (12 , 0 , - 1 )}
2664
2662
df = DataFrame (d )
2665
2663
d_err = {"x" : np .ones (12 ) * 0.2 , "y" : np .ones (12 ) * 0.4 }
@@ -2675,39 +2673,6 @@ def test_errorbar_plot(self):
2675
2673
ax = _check_plot_works (df .plot , yerr = df_err , loglog = True )
2676
2674
self ._check_has_errorbars (ax , xerr = 0 , yerr = 2 )
2677
2675
2678
- kinds = ["line" , "bar" , "barh" ]
2679
- for kind in kinds :
2680
- ax = _check_plot_works (df .plot , yerr = df_err ["x" ], kind = kind )
2681
- self ._check_has_errorbars (ax , xerr = 0 , yerr = 2 )
2682
-
2683
- ax = _check_plot_works (df .plot , yerr = d_err , kind = kind )
2684
- self ._check_has_errorbars (ax , xerr = 0 , yerr = 2 )
2685
-
2686
- ax = _check_plot_works (df .plot , yerr = df_err , xerr = df_err , kind = kind )
2687
- self ._check_has_errorbars (ax , xerr = 2 , yerr = 2 )
2688
-
2689
- ax = _check_plot_works (
2690
- df .plot , yerr = df_err ["x" ], xerr = df_err ["x" ], kind = kind
2691
- )
2692
- self ._check_has_errorbars (ax , xerr = 2 , yerr = 2 )
2693
-
2694
- ax = _check_plot_works (df .plot , xerr = 0.2 , yerr = 0.2 , kind = kind )
2695
- self ._check_has_errorbars (ax , xerr = 2 , yerr = 2 )
2696
-
2697
- with tm .assert_produces_warning (UserWarning ):
2698
- # _check_plot_works as this function creates
2699
- # subplots inside, which leads to warnings like this:
2700
- # UserWarning: To output multiple subplots,
2701
- # the figure containing the passed axes is being cleared
2702
- # Similar warnings were observed in GH #13188
2703
- _check_plot_works (
2704
- df .plot , yerr = df_err , xerr = df_err , subplots = True , kind = kind
2705
- )
2706
- fig = plt .gcf ()
2707
- axes = fig .get_axes ()
2708
- for ax in axes :
2709
- self ._check_has_errorbars (ax , xerr = 1 , yerr = 1 )
2710
-
2711
2676
ax = _check_plot_works (
2712
2677
(df + 1 ).plot , yerr = df_err , xerr = df_err , kind = "bar" , log = True
2713
2678
)
@@ -2724,8 +2689,10 @@ def test_errorbar_plot(self):
2724
2689
for yerr in ["yerr" , "誤差" ]:
2725
2690
s_df = df .copy ()
2726
2691
s_df [yerr ] = np .ones (12 ) * 0.2
2692
+
2727
2693
ax = _check_plot_works (s_df .plot , yerr = yerr )
2728
2694
self ._check_has_errorbars (ax , xerr = 0 , yerr = 2 )
2695
+
2729
2696
ax = _check_plot_works (s_df .plot , y = "y" , x = "x" , yerr = yerr )
2730
2697
self ._check_has_errorbars (ax , xerr = 0 , yerr = 1 )
2731
2698
@@ -2736,6 +2703,45 @@ def test_errorbar_plot(self):
2736
2703
with pytest .raises ((ValueError , TypeError )):
2737
2704
df .plot (yerr = df_err )
2738
2705
2706
+ @pytest .mark .slow
2707
+ @pytest .mark .parametrize ("kind" , ["line" , "bar" , "barh" ])
2708
+ def test_errorbar_plot_different_kinds (self , kind ):
2709
+ import matplotlib .pyplot as plt
2710
+
2711
+ d = {"x" : np .arange (12 ), "y" : np .arange (12 , 0 , - 1 )}
2712
+ df = DataFrame (d )
2713
+ d_err = {"x" : np .ones (12 ) * 0.2 , "y" : np .ones (12 ) * 0.4 }
2714
+ df_err = DataFrame (d_err )
2715
+
2716
+ ax = _check_plot_works (df .plot , yerr = df_err ["x" ], kind = kind )
2717
+ self ._check_has_errorbars (ax , xerr = 0 , yerr = 2 )
2718
+
2719
+ ax = _check_plot_works (df .plot , yerr = d_err , kind = kind )
2720
+ self ._check_has_errorbars (ax , xerr = 0 , yerr = 2 )
2721
+
2722
+ ax = _check_plot_works (df .plot , yerr = df_err , xerr = df_err , kind = kind )
2723
+ self ._check_has_errorbars (ax , xerr = 2 , yerr = 2 )
2724
+
2725
+ ax = _check_plot_works (df .plot , yerr = df_err ["x" ], xerr = df_err ["x" ], kind = kind )
2726
+ self ._check_has_errorbars (ax , xerr = 2 , yerr = 2 )
2727
+
2728
+ ax = _check_plot_works (df .plot , xerr = 0.2 , yerr = 0.2 , kind = kind )
2729
+ self ._check_has_errorbars (ax , xerr = 2 , yerr = 2 )
2730
+
2731
+ with tm .assert_produces_warning (UserWarning ):
2732
+ # _check_plot_works as this function creates
2733
+ # subplots inside, which leads to warnings like this:
2734
+ # UserWarning: To output multiple subplots,
2735
+ # the figure containing the passed axes is being cleared
2736
+ # Similar warnings were observed in GH #13188
2737
+ _check_plot_works (
2738
+ df .plot , yerr = df_err , xerr = df_err , subplots = True , kind = kind
2739
+ )
2740
+ fig = plt .gcf ()
2741
+ axes = fig .get_axes ()
2742
+ for ax in axes :
2743
+ self ._check_has_errorbars (ax , xerr = 1 , yerr = 1 )
2744
+
2739
2745
@pytest .mark .xfail (reason = "Iterator is consumed" , raises = ValueError )
2740
2746
@pytest .mark .slow
2741
2747
def test_errorbar_plot_iterator (self ):
0 commit comments