Skip to content
This repository has been archived by the owner on Nov 5, 2020. It is now read-only.

Commit

Permalink
fix: erros on log-log plots - the actual fix for #264 (close #264)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jan 31, 2020
1 parent 674a74d commit c702b19
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
],
},
install_requires=["appdirs",
"dclab[all]>=0.19.1",
"dclab[all]>=0.20.1",
"fcswrite>=0.5.0",
"h5py>=2.8.0",
"imageio>=2.3.0,<2.5.0",
Expand Down
13 changes: 6 additions & 7 deletions shapeout/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,13 @@ def _complete_config(self, measurements=None):
for d, l, mult in defs:
var = d.format(kk)
if var not in pltng:
data = mm[kk]
if sc == "log":
# this does not seem to be necessary (issue #264)
#data = np.log(data)
pass
acc = l(data) * mult
acc = mm.get_kde_spacing(mm[kk],
scale=sc,
method=l,
feat=kk)
# multiply by mult and
# round to make it look pretty in the GUI
accr = float("{:.1e}".format(acc))
accr = float("{:.1e}".format(acc * mult))
pltng[var] = accr
# Check for missing min/max values and set them to zero
for item in self.get_usable_features():
Expand Down
14 changes: 9 additions & 5 deletions shapeout/gui/plot_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import warnings

import chaco
import dclab
import numpy as np

from dclab import isoelastics
Expand Down Expand Up @@ -65,12 +66,15 @@ def get_isoelastics(mm):
return isoel


def get_kde_kwargs(x, y, kde_type, xacc, yacc):
def get_kde_kwargs(x, y, kde_type, xacc, yacc, xscale, yscale):
"""Copmutes optimal default KDE kwargs"""
kde_kwargs = {}
if kde_type == "multivariate":
kde_kwargs["bw"] = [xacc, yacc]
elif kde_type == "histogram":
# scale the x and y axes (fixes #264)
x = dclab.rtdc_dataset.RTDCBase._apply_scale(x, xscale, "x")
y = dclab.rtdc_dataset.RTDCBase._apply_scale(y, yscale, "y")
# The histogram accuracy is scaled by 1.8 to approximately
# match the multivariate kde.
try:
Expand All @@ -81,12 +85,12 @@ def get_kde_kwargs(x, y, kde_type, xacc, yacc):
biny = naninfminmaxdiff(y)/(1.8*yacc)
except:
biny = 5
binx = int(max(5, binx)) #if binx < x.size else 20
biny = int(max(5, biny)) #if biny < y.size else 20
binx = int(max(5, binx))
biny = int(max(5, biny))
kde_kwargs["bins"] = [binx, biny]
return kde_kwargs


def my_log_auto_ticks(data_low, data_high,
bound_low, bound_high,
tick_interval, use_endpoints = True):
Expand Down
4 changes: 3 additions & 1 deletion shapeout/gui/plot_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def scatter_plot(measurement, axScatter=None, square=True, panzoom=True,
sc_plot.plot((x_key, y_key), color="gray",
index_scale=scalex, value_scale=scaley)

# Display numer of events
# Display number of events
elabel = ca.PlotLabel(text="",
component=sc_plot,
vjustify="bottom",
Expand Down Expand Up @@ -229,6 +229,8 @@ def set_scatter_data(plot, mm):
kde_kwargs = plot_common.get_kde_kwargs(
x=x,
y=y,
xscale=scalex,
yscale=scaley,
kde_type=kde_type,
xacc=mm.config["plotting"]["kde accuracy "+xax],
yacc=mm.config["plotting"]["kde accuracy "+yax])
Expand Down

0 comments on commit c702b19

Please sign in to comment.