@@ -2658,8 +2658,6 @@ def test_pie_df_nan(self):
26582658
26592659 @pytest .mark .slow
26602660 def test_errorbar_plot (self ):
2661- import matplotlib .pyplot as plt
2662-
26632661 d = {"x" : np .arange (12 ), "y" : np .arange (12 , 0 , - 1 )}
26642662 df = DataFrame (d )
26652663 d_err = {"x" : np .ones (12 ) * 0.2 , "y" : np .ones (12 ) * 0.4 }
@@ -2675,39 +2673,6 @@ def test_errorbar_plot(self):
26752673 ax = _check_plot_works (df .plot , yerr = df_err , loglog = True )
26762674 self ._check_has_errorbars (ax , xerr = 0 , yerr = 2 )
26772675
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-
27112676 ax = _check_plot_works (
27122677 (df + 1 ).plot , yerr = df_err , xerr = df_err , kind = "bar" , log = True
27132678 )
@@ -2724,8 +2689,10 @@ def test_errorbar_plot(self):
27242689 for yerr in ["yerr" , "誤差" ]:
27252690 s_df = df .copy ()
27262691 s_df [yerr ] = np .ones (12 ) * 0.2
2692+
27272693 ax = _check_plot_works (s_df .plot , yerr = yerr )
27282694 self ._check_has_errorbars (ax , xerr = 0 , yerr = 2 )
2695+
27292696 ax = _check_plot_works (s_df .plot , y = "y" , x = "x" , yerr = yerr )
27302697 self ._check_has_errorbars (ax , xerr = 0 , yerr = 1 )
27312698
@@ -2736,6 +2703,47 @@ def test_errorbar_plot(self):
27362703 with pytest .raises ((ValueError , TypeError )):
27372704 df .plot (yerr = df_err )
27382705
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 (
2726+ df .plot , yerr = df_err ["x" ], xerr = df_err ["x" ], kind = kind
2727+ )
2728+ self ._check_has_errorbars (ax , xerr = 2 , yerr = 2 )
2729+
2730+ ax = _check_plot_works (df .plot , xerr = 0.2 , yerr = 0.2 , kind = kind )
2731+ self ._check_has_errorbars (ax , xerr = 2 , yerr = 2 )
2732+
2733+ with tm .assert_produces_warning (UserWarning ):
2734+ # _check_plot_works as this function creates
2735+ # subplots inside, which leads to warnings like this:
2736+ # UserWarning: To output multiple subplots,
2737+ # the figure containing the passed axes is being cleared
2738+ # Similar warnings were observed in GH #13188
2739+ _check_plot_works (
2740+ df .plot , yerr = df_err , xerr = df_err , subplots = True , kind = kind
2741+ )
2742+ fig = plt .gcf ()
2743+ axes = fig .get_axes ()
2744+ for ax in axes :
2745+ self ._check_has_errorbars (ax , xerr = 1 , yerr = 1 )
2746+
27392747 @pytest .mark .xfail (reason = "Iterator is consumed" , raises = ValueError )
27402748 @pytest .mark .slow
27412749 def test_errorbar_plot_iterator (self ):
0 commit comments