Skip to content

Commit ab1636d

Browse files
willschlitzerweiji14seisman
authored
Add parameters to histogram (#1249)
Co-authored-by: Wei Ji <[email protected]> Co-authored-by: Dongdong Tian <[email protected]>
1 parent 887fff0 commit ab1636d

File tree

1 file changed

+77
-5
lines changed

1 file changed

+77
-5
lines changed

pygmt/src/histogram.py

+77-5
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,29 @@
1010
A="horizontal",
1111
B="frame",
1212
C="cmap",
13+
D="annotate",
14+
E="barwidth",
15+
F="center",
1316
G="fill",
1417
J="projection",
18+
L="extreme",
19+
N="distribution",
20+
Q="cumulative",
1521
R="region",
22+
S="stairs",
1623
T="series",
24+
U="timestamp",
25+
V="verbose",
1726
W="pen",
27+
X="xshift",
28+
Y="yshift",
29+
Z="type",
1830
c="panel",
1931
l="label",
2032
p="perspective",
33+
t="transparency",
2134
)
22-
@kwargs_to_strings(R="sequence", T="sequence")
35+
@kwargs_to_strings(R="sequence", T="sequence", c="sequence_comma", p="sequence")
2336
def histogram(self, table, **kwargs):
2437
r"""
2538
Plots a histogram, and can read data from a file or
@@ -40,16 +53,75 @@ def histogram(self, table, **kwargs):
4053
{G}
4154
{W}
4255
{c}
43-
label : str
44-
Add a legend entry for the symbol or line being plotted.
45-
{p}
56+
annotate : bool or str
57+
[**+b**][**+f**\ *font*][**+o**\ *off*][**+r**].
58+
Annotate each bar with the count it represents. Append any of the
59+
following modifiers: Use **+b** to place the labels beneath the bars
60+
instead of above; use **+f** to change to another font than the default
61+
annotation font; use **+o** to change the offset between bar and
62+
label [6p]; use **+r** to rotate the labels from horizontal to
63+
vertical.
64+
barwidth : int or float or str
65+
*width*\ [**+o**\ *offset*].
66+
Use an alternative histogram bar width than the default set via
67+
``series``, and optionally shift all bars by an *offset*. Here
68+
*width* is either an alternative width in data units, or the user may
69+
append a valid plot dimension unit (**c**\|\ **i**\|\ **p**) for a
70+
fixed dimension instead. Optionally, all bins may be shifted along the
71+
axis by *offset*. As for *width*, it may be given in data units of
72+
plot dimension units by appending the relevant unit.
73+
center : bool
74+
Center bin on each value. [Default is left edge].
75+
distribution : bool or int or float or str
76+
[*mode*][**+p**\ *pen*].
77+
Draw the equivalent normal distribution; append desired
78+
*pen* [Default is 0.25p,black].
79+
The *mode* selects which central location and scale to use:
80+
81+
* 0 = mean and standard deviation [Default];
82+
* 1 = median and L1 scale (1.4826 \* median absolute deviation; MAD);
83+
* 2 = LMS (least median of squares) mode and scale.
84+
cumulative : bool or str
85+
[**r**].
86+
Draw a cumulative histogram by passing ``True``. Use **r** to display
87+
a reverse cumulative histogram.
88+
extreme : str
89+
**l**\|\ **h**\|\ **b**.
90+
The modifiers specify the handling of extreme values that fall outside
91+
the range set by ``series``. By default these values are ignored.
92+
Append **b** to let these values be included in the first or last
93+
bins. To only include extreme values below first bin into the first
94+
bin, use **l**, and to only include extreme values above the last bin
95+
into that last bin, use **h**.
96+
stairs : bool
97+
Draws a stairs-step diagram which does not include the internal bars
98+
of the default histogram.
4699
horizontal : bool
47100
Plot the histogram using horizonal bars instead of the
48101
default vertical bars.
49102
series : int or str or list
50-
[*min*\ /*max*\ /]\ *inc*\ [**+n**\ ]
103+
[*min*\ /*max*\ /]\ *inc*\ [**+n**\ ].
51104
Set the interval for the width of each bar in the histogram.
105+
type : int or str
106+
[*type*][**+w**].
107+
Choose between 6 types of histograms:
52108
109+
* 0 = counts [Default]
110+
* 1 = frequency_percent
111+
* 2 = log (1.0 + count)
112+
* 3 = log (1.0 + frequency_percent)
113+
* 4 = log10 (1.0 + count)
114+
* 5 = log10 (1.0 + frequency_percent).
115+
116+
To use weights provided as a second data column instead of pure counts,
117+
append **+w**.
118+
{XY}
119+
{U}
120+
{V}
121+
label : str
122+
Add a legend entry for the symbol or line being plotted.
123+
{p}
124+
{t}
53125
"""
54126
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
55127
with Session() as lib:

0 commit comments

Comments
 (0)