Skip to content
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions examples/gallery/histograms/histogram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Histogram
---------
The :meth:`pygmt.Figure.histogram` method can plot regular histograms.
Comment thread
michaelgrund marked this conversation as resolved.
"""

import numpy as np
import pygmt

np.random.seed(100)

# generate example topography data
Comment thread
michaelgrund marked this conversation as resolved.
Outdated
mu = 100 # mean of distribution
sigma = 25 # standard deviation of distribution
data = mu + sigma * np.random.randn(521)
Comment thread
michaelgrund marked this conversation as resolved.
Outdated

fig = pygmt.Figure()

fig.histogram(
table=data,
# generate evenly spaced bins by increments of 5
series=5,
# use red3 as color fill for the bars
fill="red3",
# define the frame, add title and set background color to
# lightgray, add annotations for x and y axis
frame=['WSne+t"Histogram"+glightgray', 'x+l"Topography (m)"', 'y+l"Counts"'],
Comment thread
michaelgrund marked this conversation as resolved.
Outdated
# use a pen size of 1p to draw the outlines
pen="1p",
# choose histogram type 0 = counts [default]
type=0,
)

fig.show()