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