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

[WIP] Smart color scale: add percentile limits for smart color scale. #1259

Conversation

Dominik-Vogel
Copy link
Contributor

@Dominik-Vogel Dominik-Vogel commented Sep 6, 2018

This is marked as WIP as it will need to be merged together with the corresponding qdev wrappers pr.

Enable to limit the maximum percentage of datapoints that may be clipped by the smart color scale on either side of the distribution.
This method has the advantage not enable to control how much to discard of a signal on a noisy background as an outlier. The simulated data tries to resemble a relevant measurement situation.

Side effects:

  • includes a ipynb stub for an overview of all tutorials
  • fixes the issue of plot_by_id not using the color map as defined in qcodesrc.json

no smart color scale:
noscaling

no limiting of percentiles:
iqr

with limiting percentiles = 0.5
0 5pc

@codecov
Copy link

codecov bot commented Sep 6, 2018

Codecov Report

Merging #1259 into master will increase coverage by 1.52%.
The diff coverage is 82.89%.

@@            Coverage Diff             @@
##           master    #1259      +/-   ##
==========================================
+ Coverage   70.92%   72.45%   +1.52%     
==========================================
  Files          74       74              
  Lines        8352     8415      +63     
==========================================
+ Hits         5924     6097     +173     
+ Misses       2428     2318     -110

@Dominik-Vogel Dominik-Vogel changed the title [WIP] smart color scale: add percentile limits for smart color scale. Smart color scale: add percentile limits for smart color scale. Sep 6, 2018
@jenshnielsen
Copy link
Collaborator

jenshnielsen commented Sep 7, 2018

It would be super cool if we marked the clipped areas. The following prototype does that

import matplotlib.pyplot as plt
import numpy as np

cmap = plt.cm.get_cmap("viridis")
cmap.set_over('magenta')
cmap.set_under('cyan')
fig, ax = plt.subplots(1,1)
pc = ax.pcolormesh(np.random.rand(100,100), cmap=cmap)
cb =fig.colorbar(pc, extend='both')
pc.set_clim(0.1, 0.9)

index

@Dominik-Vogel
Copy link
Contributor Author

That is great! Thank you for the code, I initially also tried that but couldn't get it to work. I'll include this feature.

@@ -177,7 +184,8 @@ def plot_by_id(run_id: int,
if rescale_axes:
_rescale_ticks_and_units(ax, data, colorbar)
if smart_colorscale:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a info log message here with the limits used and how much is clipped

@Dominik-Vogel
Copy link
Contributor Author

I just remembered the problem: It is all fine to set up the extend as you said, but I need to set it up after the colorbar has been created, and this does not seem to work well....

@Dominik-Vogel
Copy link
Contributor Author

Ok finally found it @jenshnielsen . It seems to be an inconsistency in matplotlib. I will also need to redefine the slice that defines the points inside the colorbar:

cb.extend = 'both'
cb._inside = cb._slice_dict[cb.extend]
cb.mappable.set_clim(0, 0.3)

Maybe we can make a PR for matplotlib next week...

@Dominik-Vogel
Copy link
Contributor Author

Dominik-Vogel commented Sep 14, 2018

Now I get :-) :

axes, cb = plot_by_id(54,smart_colorscale=False)
apply_auto_color_scale(cb[0], cutoff_percentile=(0.5,0.5))

image

The lower part is not cutoff because it does not fall into the criterium of the IQR-selector.

@Dominik-Vogel Dominik-Vogel changed the title Smart color scale: add percentile limits for smart color scale. [WIP] Smart color scale: add percentile limits for smart color scale. Oct 1, 2018
docs/Makefile Outdated
jupyter-nbconvert --to rst 'examples/driver_examples/*.ipynb' --output-dir='_notebooks/driver_examples'
jupyter-nbconvert --to rst 'examples/benchmarking/*.ipynb' --output-dir='_notebooks/benchmarking'
jupyter-nbconvert --to rst "examples\plotting\*.ipynb" --ExecutePreprocessor.timeout=600 --ExecutePreprocessor.kernel_name=python3 --output-dir="_notebooks\plotting"
cp -R "examples/files" "_notebooks/files"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is indentation ok? (it probably does not matter though... i forgot)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that is apparently two spaces vs one tab...

@Dominik-Vogel Dominik-Vogel merged commit 7dee54d into microsoft:master Oct 4, 2018
giulioungaretti pushed a commit that referenced this pull request Oct 4, 2018
Merge: b39b800 c8e3b17
Author: Dominik Vogel <30660470+Dominik-Vogel@users.noreply.github.com>

    Merge pull request #1259 from Dominik-Vogel/smart_colorscale_limit_to_percentile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants