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

Improved plotting of pre-shaped 2d data #3024

Merged

Conversation

jenshnielsen
Copy link
Collaborator

@jenshnielsen jenshnielsen commented May 18, 2021

After the predefined shape was added to the dataset non measured data is filled with nans. This updates the 2d pcolormesh plot to handle this.

It does this by bypassing the logic that checks for shape since this is no longer needed. However Matplotlib cannot handle a pcolormesh plot where the x and y coordinates are nans so some logic is needed to ensure this is clipped correctly. There are two use cases to consider. If the data is on a rectilinear grid we can plot all rows and columns that contain non nan setpoints. For the other case of non rectilinear grid we currently fall back to flattening the data again and removing all nans. This may not be the optimal solution but is identical to what we had before introducing shapes.

This furthermore avoids using significant resources to find the right plot type when the plot type is already given.
For shaped data we pass the gridded x and y data directly to matplotlib and avoid having to do any reshaping.

We upgrade the Matplotlib requirements to 3.3 to avoid having to interpolate the edges of the individual patches but rely on Matplotlib to do that.

@ThorvaldLarsen can you check if this resolves #2995

@codecov
Copy link

codecov bot commented May 19, 2021

Codecov Report

Merging #3024 (0b4a53a) into master (8a65e59) will increase coverage by 0.01%.
The diff coverage is 98.63%.

@@            Coverage Diff             @@
##           master    #3024      +/-   ##
==========================================
+ Coverage   65.49%   65.51%   +0.01%     
==========================================
  Files         213      213              
  Lines       28456    28491      +35     
==========================================
+ Hits        18638    18666      +28     
- Misses       9818     9825       +7     

@jenshnielsen jenshnielsen added this to the 0.26.0 milestone May 19, 2021
@ThorvaldLarsen
Copy link
Contributor

@jenshnielsen Just had a quick look and everything seems to work with the current version. Updated our plotting system and will continue to test this branch in normal operation over the next couple of days. Many thanks for resolving this issue.

@jenshnielsen jenshnielsen changed the title Handle nan filler in 2d plot Improved plotting of pre-shaped 2d data May 20, 2021
@jenshnielsen jenshnielsen marked this pull request as ready for review May 20, 2021 13:49
@jenshnielsen
Copy link
Collaborator Author

@ThorvaldLarsen I ended up doing some more cleanup here. It would be great if you have a chance to test it again

@jenshnielsen
Copy link
Collaborator Author

@QCoDeS/core ready for review

qcodes/dataset/plotting.py Outdated Show resolved Hide resolved
qcodes/dataset/plotting.py Show resolved Hide resolved
@ThorvaldLarsen
Copy link
Contributor

@jenshnielsen will get our system updated and try it out in production over the next couple of days. Thanks!

@ThorvaldLarsen
Copy link
Contributor

@jenshnielsen @trevormorgan tested across our current database and everything has been working great so far. I would say this is ready for merging.

Only minor thing I ran into was for a completely empty dataset (dataset created but cancelled before any data was added) plotting fails with a "keyword error" which could be done more gracefully. This is a very rare case and for an empty dataset we obviously dont care about the plot. I think this has also been the normal behavior from the beginning and I would say perfectly fine to just leave as is.

@trevormorgan
Copy link
Contributor

Only minor thing I ran into was for a completely empty dataset (dataset created but cancelled before any data was added) plotting fails with a "keyword error" which could be done more gracefully. This is a very rare case and for an empty dataset we obviously dont care about the plot. I think this has also been the normal behavior from the beginning and I would say perfectly fine to just leave as is.

@ThorvaldLarsen thanks for the testing and feedback! This looks good to merge now so we can have it in the upcoming release. I'll make a note of this issue so we can make improvements for a more graceful failure due to an empty dataset but let's handle that in another PR.

@trevormorgan trevormorgan merged commit 6dba3db into microsoft:master May 25, 2021
@jenshnielsen jenshnielsen deleted the handle_nan_filler_in_2d_plot branch May 25, 2021 05:44
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.

Plot_dataset for partially completed 2D
4 participants