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

Commit

Permalink
Workaround for plotting contours on a log scale using enthought/chaco…
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Apr 9, 2019
1 parent e94fc27 commit a0d02f7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
- Pin numpy version to <=1.13.0 to prevent ValueError caused
by chaco testing whether an array object is contained in another
object
- Bugfixes:
- Workaround for plotting contours on a log scale using
https://github.com/enthought/chaco/issues/300
0.9.1
- Add tooltips for box filter settings
- Rename *Statistical analysis* to *Statistical summary* in batch menu
Expand Down
7 changes: 0 additions & 7 deletions shapeout/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,13 +588,6 @@ def SetParameters(self, newcfg):
pops.append(skey)
for skey in pops:
pl.pop(skey)
# Address issue with faulty contour plot on log scale
# https://github.com/enthought/chaco/issues/300
if (("scale x" in pl and pl["scale x"] == "log") or
("scale y" in pl and pl["scale y"] == "log")):
warnings.warn(
"Disabling contour plot because of chaco issue #300!")
pl["contour plot"] = False
# check for inverted plotting ranges
for feat in dfn.scalar_feature_names:
fmin = feat + " min"
Expand Down
2 changes: 1 addition & 1 deletion shapeout/gui/controls_contourplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _box_from_cfg_contour(self, analysis):
# Remove all items that have nothing to do with plotting
xax, yax = analysis.GetPlotAxes()
for topic in ["kde accuracy", "contour accuracy"]:
dellist = list()
dellist = []
for item in items:
# item: e.g. ("kde accuracy fl2area", 1000)
if item[0].startswith(topic):
Expand Down
30 changes: 25 additions & 5 deletions shapeout/gui/plot_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def contour_plot(analysis, axContour=None, wxtext=False, square=True):
scalex = mm.config["plotting"]["scale x"].lower()
scaley = mm.config["plotting"]["scale y"].lower()

contour_plot.index_scale = scalex
contour_plot.value_scale = scaley

# Add isoelastics only if all measurements have the same channel width
try:
analysis.get_config_value("setup", "channel width")
Expand All @@ -54,9 +57,10 @@ def contour_plot(analysis, axContour=None, wxtext=False, square=True):
y_key = 'isoel_y'+str(ii)
pd.set_data(x_key, data[:,0])
pd.set_data(y_key, data[:,1])
contour_plot.plot((x_key, y_key), color="gray",
index_scale=scalex, value_scale=scaley)

contour_plot.plot((x_key, y_key),
color="gray",
index_scale=scalex,
value_scale=scaley)
#colors = [ "".join(map(chr, np.array(c[:3]*255,dtype=int))).encode('hex') for c in colors ]

set_contour_data(contour_plot, analysis)
Expand Down Expand Up @@ -166,7 +170,13 @@ def set_contour_data(plot, analysis):
else:
styles = "solid"
widths = cwidth
plot.contour_plot(cname,

scalex = mm.config["plotting"]["scale x"].lower()
scaley = mm.config["plotting"]["scale y"].lower()
plot.index_scale = scalex
plot.value_scale = scaley

cplot = plot.contour_plot(cname,
name=cname,
type="line",
xbounds=(X[0][0], X[0][-1]),
Expand All @@ -175,4 +185,14 @@ def set_contour_data(plot, analysis):
colors=mm.config["plotting"]["contour color"],
styles=styles,
widths=widths,
)
)[0]
if scalex == "log":
cplot.index_mapper._xmapper = ca.LogMapper(
range=cplot.index_range.x_range,
screen_bounds=cplot.index_mapper.screen_bounds[:2]
)
if scaley == "log":
cplot.index_mapper._ymapper = ca.LogMapper(
range=cplot.index_range.y_range,
screen_bounds=cplot.index_mapper.screen_bounds[2:]
)

0 comments on commit a0d02f7

Please sign in to comment.