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-35371: Add reference line to plots #49

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion python/lsst/analysis/drp/scatterPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def scatterPlotWithTwoHists(self, catPlot, plotInfo, sumStats, yLims=False, xLim
fig.text(xPos, 0.020, statText, bbox=bbox, transform=fig.transFigure, fontsize=6)

if self.config.plot2DHist:
histIm = ax.hexbin(xs[inside], ys[inside], gridsize=75, cmap=cmap, mincnt=1, zorder=-2)
histIm = ax.hexbin(xs[inside], ys[inside], gridsize=75, cmap=cmap, mincnt=1, zorder=-3)

# If there are not many sources being used for the
# statistics then plot them individually as just
Expand Down Expand Up @@ -578,6 +578,13 @@ def scatterPlotWithTwoHists(self, catPlot, plotInfo, sumStats, yLims=False, xLim
linesForLegend.append(sigMadLine)
histIm = None

# Set color and line style for the horizontal reference line at 0
hlineColor = 'black'
hlineStyle = (0, (1, 4))

# Add a horizontal reference line at 0 to the scatter plot
ax.axhline(0, color=hlineColor, ls=hlineStyle, alpha=0.7, zorder=-2)

# Set the scatter plot limits
if len(ysStars) > 0:
plotMed = np.nanmedian(ysStars)
Expand Down Expand Up @@ -656,6 +663,9 @@ def scatterPlotWithTwoHists(self, catPlot, plotInfo, sumStats, yLims=False, xLim
sideHist.hist(ysStars[lowSn[sources]], bins=bins, color="midnightblue", histtype="step",
orientation="horizontal", log=True, ls=":")

# Add a horizontal reference line at 0 to the side histogram
sideHist.axhline(0, color=hlineColor, ls=hlineStyle, alpha=0.7, zorder=-2)

sideHist.axes.get_yaxis().set_visible(False)
sideHist.set_xlabel("Number", fontsize=8)
if self.config.plot2DHist and histIm is not None:
Expand Down
2 changes: 2 additions & 0 deletions tests/data/test_scatterPlot_lines/line_23.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0.000000000000000000e+00 0.000000000000000000e+00
1.000000000000000000e+00 0.000000000000000000e+00
2 changes: 2 additions & 0 deletions tests/data/test_scatterPlot_lines/line_24.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0.000000000000000000e+00 0.000000000000000000e+00
1.000000000000000000e+00 0.000000000000000000e+00