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
DM-42642: Introduce MatrixPlot plot type to analysis_tools #190
Conversation
4832c1a
to
c44ea87
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly fine; see specific comments.
The resulting figure. | ||
""" | ||
matrix = data[self.matrixKey] | ||
if self.vmin is not None and self.vmax is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should be able to manually override either one of vmin/vmax and still let the other be determined automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Done!
axis.set_tick_params(which="minor", length=0) | ||
else: | ||
# Set the desired tick values and labels if provided. | ||
if self.xAxisTickValues is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting that If it's left like this instead of if self.xAxisTickValues
, then setting self.xAxisTickValues=[]
(instead of None) will remove all ticks. I think it's ok to support remove axis ticks and labels but maybe there should be a note about this in the relevant config field docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new approach uses if self.xAxisTickValues
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, so you don't want users to be able to turn them off entirely (by supplying an empty list)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to if self.xAxisTickValues is not None
; this allows supplying an empty list.
c44ea87
to
bf76b18
Compare
76075d6
to
d5ce4f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more notes; I'm assuming the rebase will be trivial.
) | ||
|
||
xAxisTickLabels = DictField[float, str]( | ||
doc="Dictionary of x-axis tick positions and labels. These can work independent of " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are applied as minor ticks, right? Maybe add a longer note about that in the class docstring, especially if it's possible to misconfigure them such that the major and minor tick labels overlap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are not restricted to specific tick types. If any keys in this DictField
do not align with major ticks provided by xAxisTickValues
(or automatically set by matplotlib), they will be set as minor ticks. Thus, these tick labels operate independently, meaning their corresponding positions do not need to match those in xAxisTickValues
or anything else. The code automatically adjusts to handle any overlaps caused by user input. I'm not sure if someone can misconfigure this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provided additional clarification to the doc.
|
||
xAxisTickLabels = DictField[float, str]( | ||
doc="Dictionary of x-axis tick positions and labels. These can work independent of " | ||
"`xAxisTickValues`.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this reference is going to be parsed in the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen examples in the code base, e.g. here. It doesn't have to be clickable.
default_limits = (None, None) | ||
|
||
# Set the value range using overrides or defaults. | ||
vrange = (self.vmin or default_limits[0], self.vmax or default_limits[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you still need to put default_limits[0] if self.vmin is None else self.vmin
in case self.vmin == 0
, which evaluates as False
(and same for vmax although I don't think vmax=0 would work very well if at all).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, done!
axis.set_tick_params(which="minor", length=0) | ||
else: | ||
# Set the desired tick values and labels if provided. | ||
if self.xAxisTickValues is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, so you don't want users to be able to turn them off entirely (by supplying an empty list)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review! I'll proceed with the rebase as soon as you're satisfied with the updates.
) | ||
|
||
xAxisTickLabels = DictField[float, str]( | ||
doc="Dictionary of x-axis tick positions and labels. These can work independent of " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are not restricted to specific tick types. If any keys in this DictField
do not align with major ticks provided by xAxisTickValues
(or automatically set by matplotlib), they will be set as minor ticks. Thus, these tick labels operate independently, meaning their corresponding positions do not need to match those in xAxisTickValues
or anything else. The code automatically adjusts to handle any overlaps caused by user input. I'm not sure if someone can misconfigure this.
) | ||
|
||
xAxisTickLabels = DictField[float, str]( | ||
doc="Dictionary of x-axis tick positions and labels. These can work independent of " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provided additional clarification to the doc.
|
||
xAxisTickLabels = DictField[float, str]( | ||
doc="Dictionary of x-axis tick positions and labels. These can work independent of " | ||
"`xAxisTickValues`.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen examples in the code base, e.g. here. It doesn't have to be clickable.
default_limits = (None, None) | ||
|
||
# Set the value range using overrides or defaults. | ||
vrange = (self.vmin or default_limits[0], self.vmax or default_limits[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, done!
axis.set_tick_params(which="minor", length=0) | ||
else: | ||
# Set the desired tick values and labels if provided. | ||
if self.xAxisTickValues is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to if self.xAxisTickValues is not None
; this allows supplying an empty list.
71e4859
to
537b17e
Compare
|
||
# Set the colorbar and draw the image. | ||
norm = ImageNormalize(vmin=vrange[0], vmax=vrange[1]) | ||
img = ax.imshow(matrix, interpolation="none", norm=norm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the origin
kwarg should be configurable here (I prefer lower
which is unambiguously the correct choice for our actual CCD images but making it a ChoiceField[str]
with upper
as the default is fine if that's the convention for covariance plots for the camera team).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I have made it configurable so that we can revisit this decision in the future.
c3b3ff6
to
e31c9a7
Compare
e31c9a7
to
b61e544
Compare
No description provided.