@@ -385,6 +385,45 @@ def hist_frame(
385
385
"""
386
386
387
387
388
+ _bar_or_line_doc = """
389
+ Parameters
390
+ ----------
391
+ x : label or position, optional
392
+ Allows plotting of one column versus another. If not specified,
393
+ the index of the DataFrame is used.
394
+ y : label or position, optional
395
+ Allows plotting of one column versus another. If not specified,
396
+ all numerical columns are used.
397
+ color : str, array_like, or dict, optional
398
+ The color for each of the DataFrame's columns. Possible values are:
399
+
400
+ - A single color string referred to by name, RGB or RGBA code,
401
+ for instance 'red' or '#a98d19'.
402
+
403
+ - A sequence of color strings referred to by name, RGB or RGBA
404
+ code, which will be used for each column recursively. For
405
+ instance ['green','yellow'] each column's %(kind)s will be filled in
406
+ green or yellow, alternatively.
407
+
408
+ - A dict of the form {column name : color}, so that each column will be
409
+ colored accordingly. For example, if your columns are called `a` and
410
+ `b`, then passing {'a': 'green', 'b': 'red'} will color %(kind)ss for
411
+ column `a` in green and %(kind)ss for column `b` in red.
412
+
413
+ .. versionadded:: 1.1.0
414
+
415
+ **kwargs
416
+ Additional keyword arguments are documented in
417
+ :meth:`DataFrame.plot`.
418
+
419
+ Returns
420
+ -------
421
+ matplotlib.axes.Axes or np.ndarray of them
422
+ An ndarray is returned with one :class:`matplotlib.axes.Axes`
423
+ per column when ``subplots=True``.
424
+ """
425
+
426
+
388
427
@Substitution (backend = "" )
389
428
@Appender (_boxplot_doc )
390
429
def boxplot (
@@ -848,46 +887,8 @@ def __call__(self, *args, **kwargs):
848
887
849
888
__call__ .__doc__ = __doc__
850
889
851
- def line ( self , x = None , y = None , ** kwargs ):
890
+ @ Appender (
852
891
"""
853
- Plot Series or DataFrame as lines.
854
-
855
- This function is useful to plot lines using DataFrame's values
856
- as coordinates.
857
-
858
- Parameters
859
- ----------
860
- x : int or str, optional
861
- Columns to use for the horizontal axis.
862
- Either the location or the label of the columns to be used.
863
- By default, it will use the DataFrame indices.
864
- y : int, str, or list of them, optional
865
- The values to be plotted.
866
- Either the location or the label of the columns to be used.
867
- By default, it will use the remaining DataFrame numeric columns.
868
- color : str, int, array_like, or dict, optional
869
- The color for each of the DataFrame's columns. Possible values are:
870
-
871
- - A single color string referred to by name, RGB or RGBA code,
872
- for instance 'red' or '#a98d19'.
873
-
874
- - A sequence of color strings referred to by name, RGB or RGBA
875
- code, which will be used for each column recursively. For
876
- instance ['green','yellow'] each column's line will be coloured in
877
- green or yellow, alternatively.
878
-
879
- - A dict of the form {column name : color}, so that each column will be
880
- colored accordingly. For example, if your columns are called `a` and `b`,
881
- then passing {'a': 'green', 'b': 'red'} will color lines for column `a` in
882
- green and lines for column `b` in red.
883
- **kwargs
884
- Keyword arguments to pass on to :meth:`DataFrame.plot`.
885
-
886
- Returns
887
- -------
888
- :class:`matplotlib.axes.Axes` or :class:`numpy.ndarray`
889
- Return an ndarray when ``subplots=True``.
890
-
891
892
See Also
892
893
--------
893
894
matplotlib.pyplot.plot : Plot y versus x as lines and/or markers.
@@ -940,51 +941,20 @@ def line(self, x=None, y=None, **kwargs):
940
941
941
942
>>> lines = df.plot.line(x='pig', y='horse')
942
943
"""
943
- return self (kind = "line" , x = x , y = y , ** kwargs )
944
-
945
- def bar (self , x = None , y = None , ** kwargs ):
944
+ )
945
+ @Substitution (kind = "line" )
946
+ @Appender (_bar_or_line_doc )
947
+ def line (self , x = None , y = None , ** kwargs ):
946
948
"""
947
- Vertical bar plot.
948
-
949
- A bar plot is a plot that presents categorical data with
950
- rectangular bars with lengths proportional to the values that they
951
- represent. A bar plot shows comparisons among discrete categories. One
952
- axis of the plot shows the specific categories being compared, and the
953
- other axis represents a measured value.
954
-
955
- Parameters
956
- ----------
957
- x : label or position, optional
958
- Allows plotting of one column versus another. If not specified,
959
- the index of the DataFrame is used.
960
- y : label or position, optional
961
- Allows plotting of one column versus another. If not specified,
962
- all numerical columns are used.
963
- color : str, int, array_like, or dict, optional
964
- The color for each of the DataFrame's columns. Possible values are:
965
-
966
- - A single color string referred to by name, RGB or RGBA code,
967
- for instance 'red' or '#a98d19'.
968
-
969
- - A sequence of color strings referred to by name, RGB or RGBA
970
- code, which will be used for each column recursively. For
971
- instance ['green','yellow'] each column's bar will be filled in
972
- green or yellow, alternatively.
973
-
974
- - A dict of the form {column name : color}, so that each column will be
975
- colored accordingly. For example, if your columns are called `a` and `b`,
976
- then passing {'a': 'green', 'b': 'red'} will color bars for column `a` in
977
- green and bars for column `b` in red.
978
- **kwargs
979
- Additional keyword arguments are documented in
980
- :meth:`DataFrame.plot`.
949
+ Plot Series or DataFrame as lines.
981
950
982
- Returns
983
- -------
984
- matplotlib.axes.Axes or np.ndarray of them
985
- An ndarray is returned with one :class:`matplotlib.axes.Axes`
986
- per column when ``subplots=True``.
951
+ This function is useful to plot lines using DataFrame's values
952
+ as coordinates.
953
+ """
954
+ return self (kind = "line" , x = x , y = y , ** kwargs )
987
955
956
+ @Appender (
957
+ """
988
958
See Also
989
959
--------
990
960
DataFrame.plot.barh : Horizontal bar plot.
@@ -1050,47 +1020,24 @@ def bar(self, x=None, y=None, **kwargs):
1050
1020
:context: close-figs
1051
1021
1052
1022
>>> ax = df.plot.bar(x='lifespan', rot=0)
1023
+ """
1024
+ )
1025
+ @Substitution (kind = "bar" )
1026
+ @Appender (_bar_or_line_doc )
1027
+ def bar (self , x = None , y = None , ** kwargs ):
1053
1028
"""
1054
- return self (kind = "bar" , x = x , y = y , ** kwargs )
1055
-
1056
- def barh (self , x = None , y = None , ** kwargs ):
1057
- """
1058
- Make a horizontal bar plot.
1029
+ Vertical bar plot.
1059
1030
1060
- A horizontal bar plot is a plot that presents quantitative data with
1031
+ A bar plot is a plot that presents categorical data with
1061
1032
rectangular bars with lengths proportional to the values that they
1062
1033
represent. A bar plot shows comparisons among discrete categories. One
1063
1034
axis of the plot shows the specific categories being compared, and the
1064
1035
other axis represents a measured value.
1036
+ """
1037
+ return self (kind = "bar" , x = x , y = y , ** kwargs )
1065
1038
1066
- Parameters
1067
- ----------
1068
- x : label or position, default DataFrame.index
1069
- Column to be used for categories.
1070
- y : label or position, default All numeric columns in dataframe
1071
- Columns to be plotted from the DataFrame.
1072
- color : str, int, array_like, or dict, optional
1073
- The color for each of the DataFrame's columns. Possible values are:
1074
-
1075
- - A single color string referred to by name, RGB or RGBA code,
1076
- for instance 'red' or '#a98d19'.
1077
-
1078
- - A sequence of color strings referred to by name, RGB or RGBA
1079
- code, which will be used for each column recursively. For
1080
- instance ['green','yellow'] each column's bar will be filled in
1081
- green or yellow, alternatively.
1082
-
1083
- - A dict of the form {column name : color}, so that each column will be
1084
- colored accordingly. For example, if your columns are called `a` and `b`,
1085
- then passing {'a': 'green', 'b': 'red'} will color bars for column `a` in
1086
- green and bars for column `b` in red.
1087
- **kwargs
1088
- Keyword arguments to pass on to :meth:`DataFrame.plot`.
1089
-
1090
- Returns
1091
- -------
1092
- :class:`matplotlib.axes.Axes` or numpy.ndarray of them
1093
-
1039
+ @Appender (
1040
+ """
1094
1041
See Also
1095
1042
--------
1096
1043
DataFrame.plot.bar: Vertical bar plot.
@@ -1152,6 +1099,19 @@ def barh(self, x=None, y=None, **kwargs):
1152
1099
>>> df = pd.DataFrame({'speed': speed,
1153
1100
... 'lifespan': lifespan}, index=index)
1154
1101
>>> ax = df.plot.barh(x='lifespan')
1102
+ """
1103
+ )
1104
+ @Substitution (kind = "bar" )
1105
+ @Appender (_bar_or_line_doc )
1106
+ def barh (self , x = None , y = None , ** kwargs ):
1107
+ """
1108
+ Make a horizontal bar plot.
1109
+
1110
+ A horizontal bar plot is a plot that presents quantitative data with
1111
+ rectangular bars with lengths proportional to the values that they
1112
+ represent. A bar plot shows comparisons among discrete categories. One
1113
+ axis of the plot shows the specific categories being compared, and the
1114
+ other axis represents a measured value.
1155
1115
"""
1156
1116
return self (kind = "barh" , x = x , y = y , ** kwargs )
1157
1117
0 commit comments