Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clip size of scatter markers below/above limits #1609

Merged
merged 1 commit into from
Mar 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ v0.13.0 (unreleased)
* Added a new selection mode that always forces the creation of a new subset.
[#1525]

v0.12.6 (unreleased)
--------------------

* Fixed size of markers when value for size is out of vmin/vmax range. [#1609]

v0.12.5 (unreleased)
--------------------

Expand Down
9 changes: 7 additions & 2 deletions glue/viewers/scatter/layer_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,13 @@ def _update_visual_attributes(self, changed, force=False):
else:
s = self.layer[self.state.size_att].ravel()
s = ((s - self.state.size_vmin) /
(self.state.size_vmax - self.state.size_vmin)) * 30
s *= self.state.size_scaling
(self.state.size_vmax - self.state.size_vmin))
# The following ensures that the sizes are in the
# range 3 to 30 before the final size_scaling.
np.clip(s, 0, 1, out=s)
s *= 0.95
s += 0.05
s *= (30 * self.state.size_scaling)

# Note, we need to square here because for scatter, s is actually
# proportional to the marker area, not radius.
Expand Down
4 changes: 3 additions & 1 deletion glue/viewers/scatter/python_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ def python_export_scatter_layer(layer, *args):

if layer.state.size_mode == 'Linear':

imports = ['import numpy as np']

script += "# Set up size values\n"
script += "sizes = layer_data['{0}']\n".format(layer.state.size_att.label)
script += "size_vmin = {0}\n".format(layer.state.size_vmin)
script += "size_vmax = {0}\n".format(layer.state.size_vmax)
script += "sizes = 30 * (sizes - size_vmin) / (size_vmax - size_vmin) * {0}\n\n".format(layer.state.size_scaling)
script += "sizes = 30 * (np.clip((sizes - size_vmin) / (size_vmax - size_vmin), 0, 1) * 0.95 + 0.05) * {0}\n\n".format(layer.state.size_scaling)

if MATPLOTLIB_LT_20:
imports = ['import numpy as np']
Expand Down