Skip to content

Commit

Permalink
Add properties color and linewidth to plot_contour().
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaselsteiner committed Sep 22, 2020
1 parent 04f0d60 commit 46bfc54
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ def test_plot_contour_and_sample(self):
plot_contour(x=contour_tz_20,
y=contour_hs_20,
ax=ax,
color='gold',
linewidth=5,
contour_label='20-yr IFORM contour',
x_label=label_tz,
y_label=label_hs,
line_style='b-',
sample_plot_data=plotted_sample,
x_lim=(0, 19),
upper_ylim=15,
Expand Down
17 changes: 12 additions & 5 deletions viroconcom/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ def plot_dependence_functions(


def plot_contour(x, y, ax=None, contour_label=None, x_label=None, y_label=None,
line_style='b-', alpha=1, sample_plot_data=None, x_lim=None,
upper_ylim=None, median_x=None, median_y=None, median_style='r-',
line_style='b-', color=None, linewidth=None, alpha=1,
sample_plot_data=None, x_lim=None, upper_ylim=None,
median_x=None, median_y=None, median_style='r-',
median_label='median of x2|x1'):
"""
Plots the environmental contour.
Expand All @@ -305,7 +306,12 @@ def plot_contour(x, y, ax=None, contour_label=None, x_label=None, y_label=None,
y_label : str, optional (defaults to None)
Label for the y-axis.
line_style : str, optional (defaults to 'b-')
Matplotlib line style.
Matplotlib line style. Will be ignored if 'color' or 'lindwidth' is
specified.
color : any matplotlib color, optional (defaults to None)
Color of the line.
linewidth : float value in points, optional (defaults to None)
Width of the line.
alpha : float, optional (default to 1)
Alpha value (transparency) for the contour's line.
sample_plot_data : SamplePlotData, optional (defaults to None)
Expand Down Expand Up @@ -337,10 +343,11 @@ def plot_contour(x, y, ax=None, contour_label=None, x_label=None, y_label=None,
# Plot the contour and, if provided, also the sample.
if sample_plot_data:
plot_sample(sample_plot_data, ax=ax)
if contour_label:
if color is None and linewidth is None:
ax.plot(xplot, yplot, line_style, alpha=alpha, label=contour_label)
else:
ax.plot(xplot, yplot, line_style, alpha=alpha)
ax.plot(xplot, yplot, color=color, linewidth=linewidth, alpha=alpha,
label=contour_label)
if median_x is not None:
ax.plot(median_x, median_y, median_style, label=median_label)

Expand Down
2 changes: 1 addition & 1 deletion viroconcom/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.4.0'
__version__ = '1.4.1'

0 comments on commit 46bfc54

Please sign in to comment.