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

DM-42642: Introduce MatrixPlot plot type to analysis_tools #190

Merged
merged 1 commit into from Feb 22, 2024

Conversation

enourbakhsh
Copy link
Contributor

No description provided.

@enourbakhsh enourbakhsh force-pushed the tickets/DM-42642 branch 6 times, most recently from 4832c1a to c44ea87 Compare January 30, 2024 01:37
Copy link
Contributor

@taranu taranu left a 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.

python/lsst/analysis/tools/actions/plot/matrixPlot.py Outdated Show resolved Hide resolved
python/lsst/analysis/tools/actions/plot/matrixPlot.py Outdated Show resolved Hide resolved
python/lsst/analysis/tools/actions/plot/matrixPlot.py Outdated Show resolved Hide resolved
python/lsst/analysis/tools/actions/plot/matrixPlot.py Outdated Show resolved Hide resolved
python/lsst/analysis/tools/actions/plot/matrixPlot.py Outdated Show resolved Hide resolved
python/lsst/analysis/tools/actions/plot/matrixPlot.py Outdated Show resolved Hide resolved
python/lsst/analysis/tools/actions/plot/matrixPlot.py Outdated Show resolved Hide resolved
The resulting figure.
"""
matrix = data[self.matrixKey]
if self.vmin is not None and self.vmax is not None:
Copy link
Contributor

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.

Copy link
Contributor Author

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:
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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)?

Copy link
Contributor Author

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.

@enourbakhsh enourbakhsh force-pushed the tickets/DM-42642 branch 2 times, most recently from 76075d6 to d5ce4f6 Compare February 7, 2024 23:05
@enourbakhsh enourbakhsh changed the title DM-42642: Make the MatrixPlot plot type for analysis_tools DM-42642: Introduce MatrixPlot plot type to analysis_tools Feb 8, 2024
Copy link
Contributor

@taranu taranu left a 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.

python/lsst/analysis/tools/actions/plot/matrixPlot.py Outdated Show resolved Hide resolved
)

xAxisTickLabels = DictField[float, str](
doc="Dictionary of x-axis tick positions and labels. These can work independent of "
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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`.",
Copy link
Contributor

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.

Copy link
Contributor Author

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])
Copy link
Contributor

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).

Copy link
Contributor Author

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:
Copy link
Contributor

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)?

Copy link
Contributor Author

@enourbakhsh enourbakhsh left a 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 "
Copy link
Contributor Author

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 "
Copy link
Contributor Author

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`.",
Copy link
Contributor Author

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])
Copy link
Contributor Author

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:
Copy link
Contributor Author

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.

@enourbakhsh enourbakhsh force-pushed the tickets/DM-42642 branch 2 times, most recently from 71e4859 to 537b17e Compare February 21, 2024 00:34

# Set the colorbar and draw the image.
norm = ImageNormalize(vmin=vrange[0], vmax=vrange[1])
img = ax.imshow(matrix, interpolation="none", norm=norm)
Copy link
Contributor

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).

Copy link
Contributor Author

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.

@enourbakhsh enourbakhsh merged commit 01c83d5 into main Feb 22, 2024
8 checks passed
@enourbakhsh enourbakhsh deleted the tickets/DM-42642 branch February 22, 2024 04:22
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

2 participants