Skip to content

Commit

Permalink
Rename PlottedSample as requested, add __all__ statement.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaselsteiner committed May 18, 2020
1 parent 88732d5 commit ce53c16
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
28 changes: 14 additions & 14 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from viroconcom.read_write import read_ecbenchmark_dataset, read_contour
from viroconcom.plot import (plot_contour, plot_wave_breaking_limit, \
plot_marginal_fit, plot_dependence_functions, plot_confidence_interval, \
PlottedSample)
plot_marginal_fit, plot_dependence_functions, plot_confidence_interval, \
SamplePlotData)
from viroconcom.contour_analysis import points_outside

from viroconcom.params import ConstantParam, FunctionParam
Expand Down Expand Up @@ -106,14 +106,14 @@ def test_plot_contour_and_sample(self):
ax = fig.add_subplot(111)

# Plot the 20-year contour and the sample.
plotted_sample = PlottedSample(x=np.asarray(sample_tz),
y=np.asarray(sample_hs),
ax=ax,
x_inside=tz_inside,
y_inside=hs_inside,
x_outside=tz_outside,
y_outside=hs_outside,
return_period=20)
plotted_sample = SamplePlotData(x=np.asarray(sample_tz),
y=np.asarray(sample_hs),
ax=ax,
x_inside=tz_inside,
y_inside=hs_inside,
x_outside=tz_outside,
y_outside=hs_outside,
return_period=20)

plot_contour(x=contour_tz_20,
y=contour_hs_20,
Expand Down Expand Up @@ -232,10 +232,10 @@ def test_plot_confidence_interval(self):
# Plot the sample, the median contour and the confidence interval.
fig = plt.figure(figsize=(5, 5), dpi=150)
ax = fig.add_subplot(111)
plotted_sample = PlottedSample(x=np.asarray(dataset_d_v),
y=np.asarray(dataset_d_hs),
ax=ax,
label='dataset D')
plotted_sample = SamplePlotData(x=np.asarray(dataset_d_v),
y=np.asarray(dataset_d_hs),
ax=ax,
label='dataset D')
contour_labels = ['50th percentile contour',
'2.5th percentile contour',
'97.5th percentile contour']
Expand Down
13 changes: 9 additions & 4 deletions viroconcom/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
"""
Plots datasets, model fits and contour coordinates.
"""

import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

__all__ = ["plot_sample", "plot_marginal_fit", "plot_dependence_functions",
"plot_contour", "SamplePlotData", "plot_confidence_interval",
"plot_wave_breaking_limit", "hs_from_limiting_sig_wave_steepness"]


def plot_sample(plotted_sample, ax=None, do_plot_rasterized=True):
"""
Plots the sample of metocean data.
Parameters
----------
plotted_sample : PlottedSample,
plotted_sample : SamplePlotData,
The sample that should be plotted and its meta information.
"""
if ax is None:
Expand Down Expand Up @@ -288,7 +293,7 @@ def plot_contour(x, y, ax, contour_label=None, x_label=None, y_label=None,
Matplotlib line style.
alpha : float, optional (default to 1)
Alpha value (transparency) for the contour's line.
plotted_sample : PlottedSample, optional (defaults to None)
plotted_sample : SamplePlotData, optional (defaults to None)
The sample that should be plotted and its meta information.
x_lim : tuple of floats, optional (defaults to None)
x-Axis limit.
Expand Down Expand Up @@ -350,7 +355,7 @@ def plot_contour(x, y, ax, contour_label=None, x_label=None, y_label=None,
ax.xaxis.set_ticks_position('bottom')


class PlottedSample():
class SamplePlotData():
"""
Class that holds a plotted sample and its meta information.
Expand Down Expand Up @@ -441,7 +446,7 @@ def plot_confidence_interval(x_median, y_median, x_bottom, y_bottom, x_upper,
Label for the y-axis.
contour_labels : list of str, optional (defaults to [None, None, None])
Label for the environmental contours that will be used in the legend.
plotted_sample : PlottedSample, optional
plotted_sample : SamplePlotData, optional
If provided, this sample is plotted together with the contours.
"""
plot_contour(x=x_median,
Expand Down

0 comments on commit ce53c16

Please sign in to comment.