Skip to content

Commit

Permalink
wip approx
Browse files Browse the repository at this point in the history
  • Loading branch information
lepy committed Sep 25, 2018
2 parents 40d57fd + aa69c35 commit 1cfd47b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
16 changes: 12 additions & 4 deletions phuzzy/data/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,31 @@ def bootstrapping(data, df_boot, show=False):

return fig, axs

<<<<<<< HEAD
def plot_hist(x, ax=None, bins=None, normed=False, color=None, **kwargs):
x = x[~np.isnan(x)]
=======
def plot_hist(x, ax=None, bins=None, normed=True, **kwargs):

>>>>>>> aa69c3564895524ef928f88a5162c36cd9cf871f
if bins is None:
bins = 'auto'
bins, edges = np.histogram(x, bins=bins, normed=normed)
bins, edges = np.histogram(x, bins=bins)
left,right = edges[:-1],edges[1:]
X = np.array([left,right]).T.flatten()
Y = np.array([bins,bins]).T.flatten()
if normed is True:
Y = Y/float(Y.max())

if ax is None:
fig, ax = plt.subplots(1, 1, figsize=(10,5))
else:
fig = plt.gcf()

if kwargs.get("filled") is True:
ax.fill_between(X, 0, Y, label=kwargs.get("label"), color="r", alpha=kwargs.get("alpha"))
ax.fill_between(X, 0, Y, label=kwargs.get("label"), color=kwargs.get("color", "b"), alpha=kwargs.get("alpha", .3))
else:
ax.plot(X,Y, label=kwargs.get("label"), color="r", alpha=kwargs.get("alpha"))
ax.plot(X,Y, label=kwargs.get("label"), color=kwargs.get("color", "r"), alpha=kwargs.get("alpha", .8))

return fig, ax

return ax
2 changes: 1 addition & 1 deletion phuzzy/mpl/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def plot_hist(x, ax=None, bins=None, normed=1, **kwargs):
fig = plt.gcf()

if kwargs.get("filled") is True:
ax.fill_between(X, 0, Y, label=kwargs.get("label"), color=kwargs.get("color", "r"), alpha=kwargs.get("alpha", .3))
ax.fill_between(X, 0, Y, label=kwargs.get("label"), color=kwargs.get("color", "b"), alpha=kwargs.get("alpha", .3))
else:
ax.plot(X,Y, label=kwargs.get("label"), color=kwargs.get("color", "r"), alpha=kwargs.get("alpha", .8))

Expand Down
7 changes: 4 additions & 3 deletions phuzzy/shapes/superellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
"""


from phuzzy.shapes import FuzzyNumber
import numpy as np
import pandas as pd

from phuzzy.shapes import FuzzyNumber


class Superellipse(FuzzyNumber):
"""superelliptic fuzzy number
Expand Down Expand Up @@ -55,7 +56,7 @@ def shape(self, x):
r = (b - a) / 2.
m = (a + b) / 2.
choicelist = [0.,
(1. - (abs(x-m)/r)**self.m) ** (1./self.n),
(1. - (abs(x - m) / r) ** self.m) ** (1. / self.n),
0.]
return np.select(condlist, choicelist)

Expand Down

0 comments on commit 1cfd47b

Please sign in to comment.