Skip to content

Commit acb1cf9

Browse files
committed
updates based on code review
1 parent 8ffbc3d commit acb1cf9

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

examples/gallery/histograms/histogram.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,31 @@
44
The :meth:`pygmt.Figure.histogram` method can plot regular histograms.
55
"""
66

7+
import numpy as np
78
import pygmt
89

10+
np.random.seed(100)
11+
12+
# generate example topography data
13+
mu = 100 # mean of distribution
14+
sigma = 25 # standard deviation of distribution
15+
data = mu + sigma * np.random.randn(521)
16+
917
fig = pygmt.Figure()
1018

1119
fig.histogram(
12-
table="@v3206_06.txt",
13-
# specify the "region" of interest [xmin, xmax, ymin, ymax]
14-
region=[-6000, 0, 0, 30],
15-
# generate evenly spaced bins by increments of 250
16-
series=250,
20+
table=data,
21+
# generate evenly spaced bins by increments of 5
22+
series=5,
1723
# use red3 as color fill for the bars
1824
fill="red3",
1925
# define the frame, add title and set background color to
2026
# lightgray, add annotations for x and y axis
21-
frame=[
22-
'WSne+t"Histogram"+glightgray',
23-
'x+l"Topography (m)"',
24-
'y+l"Frequency"+u" %"',
25-
],
27+
frame=['WSne+t"Histogram"+glightgray', 'x+l"Topography (m)"', 'y+l"Frequency"'],
2628
# use a pen size of 1p to draw the outlines
2729
pen="1p",
28-
# choose histogram type 1 = frequency_percent
29-
type=1,
30+
# choose histogram type 1 = counts [default]
31+
type=0,
3032
)
3133

3234
fig.show()

0 commit comments

Comments
 (0)