From f39d6a055fe7823d2ded95f194185780953f04f3 Mon Sep 17 00:00:00 2001 From: Daniel Himmelstein Date: Fri, 15 Mar 2024 23:52:05 -0400 Subject: [PATCH] _bearings_distribution: bin_centers terminology --- osmnx/bearing.py | 11 ++++++----- osmnx/plot.py | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/osmnx/bearing.py b/osmnx/bearing.py index 136c0b617..3b625d98e 100644 --- a/osmnx/bearing.py +++ b/osmnx/bearing.py @@ -268,8 +268,9 @@ def _bearings_distribution( Returns ------- - bin_counts, bin_edges - Counts of bearings per bin and the bins edges. + bin_counts, bin_centers + Counts of bearings per bin and the bins' centers in degrees. + Both arrays are of length `num_bins`. """ n = num_bins * 2 bins = np.arange(n + 1) * 360 / n @@ -282,6 +283,6 @@ def _bearings_distribution( count = np.roll(count, 1) bin_counts = count[::2] + count[1::2] - # because we merged the bins, their edges are now only every other one - bin_edges = bin_edges[range(0, len(bin_edges), 2)] - return bin_counts, bin_edges + # because we merged the bins, their centers are now only every other one + bin_centers = bin_edges[range(0, len(bin_edges) - 1, 2)] + return bin_counts, bin_centers diff --git a/osmnx/plot.py b/osmnx/plot.py index 965e6eb3f..dd85e2b66 100644 --- a/osmnx/plot.py +++ b/osmnx/plot.py @@ -749,7 +749,7 @@ def plot_orientation( # noqa: PLR0913 } # get the bearings' distribution's bin counts and edges - bin_counts, bin_edges = bearing._bearings_distribution( + bin_counts, bin_centers = bearing._bearings_distribution( G, num_bins, min_length=min_length, @@ -758,7 +758,7 @@ def plot_orientation( # noqa: PLR0913 # positions: where to center each bar. ignore the last bin edge, because # it's the same as the first (i.e., 0 degrees = 360 degrees) - positions = np.radians(bin_edges[:-1]) + positions = np.radians(bin_centers) # width: make bars fill the circumference without gaps or overlaps width = 2 * np.pi / num_bins