Skip to content

Commit 2126f9e

Browse files
committed
Issue #352
axis labels were hard coded, ignoring value passed in. Also added docstring to function.
1 parent 01f61bb commit 2126f9e

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

kf_book/gaussian_internal.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,27 @@ def plot_height_std(x, lw=10):
4040
def plot_correlated_data(X, Y, xlabel=None,
4141
ylabel=None, equal=True):
4242

43+
"""Plot correlation between x and y by performing
44+
linear regression between X and Y.
45+
46+
X: x data
47+
Y: y data
48+
xlabel: str
49+
optional label for x axis
50+
ylabel: str
51+
optional label for y axis
52+
equal: bool, default True
53+
use equal scale for x and y axis
54+
"""
55+
56+
4357
plt.scatter(X, Y)
4458

4559
if xlabel is not None:
46-
plt.xlabel('Height (in)');
60+
plt.xlabel(xlabel);
4761

4862
if ylabel is not None:
49-
plt.ylabel('Weight (lbs)')
63+
plt.ylabel(ylabel)
5064

5165
# fit line through data
5266
m, b = np.polyfit(X, Y, 1)
@@ -115,4 +129,4 @@ def display_stddev_plot():
115129
ax.grid(None, 'both', lw=0)
116130

117131
if __name__ == '__main__':
118-
display_stddev_plot()
132+
display_stddev_plot()

0 commit comments

Comments
 (0)