Skip to content

Commit

Permalink
Merge pull request #182 from QMCSoftware/develop
Browse files Browse the repository at this point in the history
remove duplicate plot from discrete distrib
  • Loading branch information
alegresor committed Aug 20, 2020
2 parents c6cf48b + db4df4a commit 11f7757
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 52 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ sphinx/_build/
sphinx/_static/
sphinx/demo_rst/
sphinx/readme_rst/
node_modules/*

# Jupyter Notebooks
*checkpoint.ipynb
Expand Down
52 changes: 0 additions & 52 deletions qmcpy/discrete_distribution/_discrete_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,58 +52,6 @@ def set_seed(self, seed):
"""
raise MethodImplementationError(self, 'set_seed')

def plot(self, dim_x=0, dim_y=1, n=2**7, point_size=5, color='c', show=True, out=None):
"""
Make a scatter plot from samples. Requires dimension >= 2.
Args:
dim_x (int): index of first dimension to be plotted on horizontal axis.
dim_y (int): index of the second dimension to be plotted on vertical axis.
n (int): number of samples to draw as self.gen_samples(n)
point_size (int): ax.scatter(...,s=point_size)
color (str): ax.scatter(...,color=color)
show (bool): show plot or not?
out (str): file name to output image. If None, the image is not output
Return:
tuple: fig,ax from `fig,ax = matplotlib.pyplot.subplots(...)`
"""
if self.dimension < 2:
raise ParameterError('Plotting a discrete distribution requires dimension >=2. ')
x = self.gen_samples(n)
from matplotlib import pyplot
pyplot.rc('font', size=16)
pyplot.rc('legend', fontsize=16)
pyplot.rc('figure', titlesize=16)
pyplot.rc('axes', titlesize=16, labelsize=16)
pyplot.rc('xtick', labelsize=16)
pyplot.rc('ytick', labelsize=16)
if self.mimics == 'StdUniform':
fig,ax = pyplot.subplots(figsize=(5,5))
ax.set_xlim([0,1])
ax.set_ylim([0,1])
ax.set_xticks([0,1])
ax.set_yticks([0,1])
ax.set_aspect(1)
elif self.mimics == 'StdGaussian':
fig,ax = pyplot.subplots(figsize=(5,5))
ax.set_xlim([-3,3])
ax.set_ylim([-3,3])
ax.set_xticks([-3,3])
ax.set_yticks([-3,3])
ax.set_aspect(1)
else:
fig,ax = pyplot.subplots()
ax.set_xlabel('$x_{i,%d}$'%dim_x)
ax.set_ylabel('$x_{i,%d}$'%dim_y)
ax.scatter(x[:,dim_x],x[:,dim_y],color=color,s=point_size)
s = '$2^{%d}$'%log2(n) if log2(n)%1==0 else '%d'%n
ax.set_title(s+' %s Samples'%type(self).__name__)
fig.tight_layout()
if out: pyplot.savefig(out,dpi=250)
if show: pyplot.show()
return fig,ax

def __repr__(self):
return _univ_repr(self, "DiscreteDistribution", self.parameters)

Expand Down

0 comments on commit 11f7757

Please sign in to comment.