-
Notifications
You must be signed in to change notification settings - Fork 235
Add histogram gallery example #1272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
630dc62
Add histogram gallery example
michaelgrund 57d4eb9
formatting
michaelgrund 25e77f5
added comments
michaelgrund 8ffbc3d
update
michaelgrund acb1cf9
updates based on code review
michaelgrund 29f8b21
Apply suggestions from code review
michaelgrund f1cc1c0
Merge branch 'master' into gallery-histogram
michaelgrund db8fea8
adjusted Z alias
michaelgrund af29985
Apply suggestions from code review
michaelgrund 22f2b2c
Merge branch 'master' into gallery-histogram
michaelgrund f40a0d2
updates based on code review
michaelgrund 8dbd810
updates based on code review
michaelgrund 95508a2
Merge branch 'master' into gallery-histogram
michaelgrund cb18764
Update examples/gallery/histograms/histogram.py
michaelgrund caf9137
Merge branch 'master' into gallery-histogram
michaelgrund 1b87152
Merge branch 'master' into gallery-histogram
willschlitzer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| """ | ||
| Histogram | ||
| --------- | ||
| The :meth:`pygmt.Figure.histogram` method can plot regular histograms. | ||
| Using the ``series`` parameter allows to set the interval for the width of | ||
| each bar. The type of histogram (frequency count or percentage) can be | ||
| selected via the ``histtype`` parameter. | ||
| """ | ||
|
|
||
| import numpy as np | ||
| import pygmt | ||
|
|
||
| np.random.seed(100) | ||
|
|
||
| # generate random elevation data from a normal distribution | ||
| mean = 100 # mean of distribution | ||
| stddev = 25 # standard deviation of distribution | ||
| data = mean + stddev * np.random.randn(521) | ||
|
|
||
| fig = pygmt.Figure() | ||
|
|
||
| fig.histogram( | ||
| table=data, | ||
| # 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"Elevation (m)"', 'y+l"Counts"'], | ||
| # generate evenly spaced bins by increments of 5 | ||
| series=5, | ||
| # use red3 as color fill for the bars | ||
| fill="red3", | ||
| # use a pen size of 1p to draw the outlines | ||
| pen="1p", | ||
| # choose histogram type 0 = counts [default] | ||
| histtype=0, | ||
| ) | ||
|
|
||
| fig.show() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.