Skip to content

Commit

Permalink
Add minor ticks for XYPlot
Browse files Browse the repository at this point in the history
  • Loading branch information
arunkannawadi committed May 10, 2023
1 parent baaba0f commit 105b908
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/lsst/analysis/tools/actions/plot/xyPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import matplotlib.pyplot as plt
from lsst.pex.config import ChoiceField, DictField, Field, FieldValidationError
from matplotlib.ticker import SymmetricalLogLocator

from ...interfaces import PlotAction, Vector
from .plotUtils import addPlotInfo
Expand Down Expand Up @@ -183,14 +184,31 @@ def makePlot(self, data: KeyedData, plotInfo: Mapping[str, str] | None = None, *

if self.xScale == "symlog":
ax.set_xscale("symlog", linthresh=self.xLinThresh)
locator = SymmetricalLogLocator(
linthresh=self.xLinThresh, base=10, subs=[0.1 * ii for ii in range(1, 10)]
)
ax.xaxis.set_minor_locator(locator)
ax.axvspan(-self.xLinThresh, self.xLinThresh, color="gray", alpha=0.1)
else:
ax.set_xscale(self.xScale) # type: ignore
ax.tick_params(axis="x", which="minor")

if self.yScale == "symlog":
ax.set_yscale("symlog", linthresh=self.yLinThresh)
locator = SymmetricalLogLocator(
linthresh=self.yLinThresh, base=10, subs=[0.1 * ii for ii in range(1, 10)]
)
ax.yaxis.set_minor_locator(locator)
ax.axhspan(-self.yLinThresh, self.yLinThresh, color="gray", alpha=0.1)
else:
ax.set_yscale(self.yScale) # type: ignore
ax.tick_params(axis="y", which="minor")

if self.xScale == "symlog":
locator = SymmetricalLogLocator(linthresh=self.xLinThresh, base=10)
ax.xaxis.set_minor_locator(locator)
else:
ax.tick_params(axis="x", which="minor")

if plotInfo is not None:
fig = addPlotInfo(fig, plotInfo)
Expand Down

0 comments on commit 105b908

Please sign in to comment.