Skip to content

Commit f0a7703

Browse files
committed
Add back doctest
1 parent 4645a0d commit f0a7703

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/sage/plot/graphics.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2419,7 +2419,11 @@ def _matplotlib_tick_formatter(self, subplot, base=(10, 10),
24192419
LogFormatterMathtext(base=base[0])(n, pos).replace(
24202420
"\\mathdefault", ""))
24212421
else:
2422-
x_formatter = FuncFormatter(lambda n, pos: '$%s$' % latex(n))
2422+
# circumvent the problem of symbolic tick values (trac #34693)
2423+
if isinstance(x_locator, FixedLocator):
2424+
x_formatter = FixedFormatter(['$%s$' % latex(n) for n in x_locator.locs])
2425+
else:
2426+
x_formatter = FuncFormatter(lambda n, pos: '$%s$' % latex(n))
24232427
elif isinstance(x_formatter, (list, tuple)):
24242428
if (not isinstance(ticks[0], (list, tuple)) or
24252429
len(ticks[0]) != len(x_formatter)):

src/sage/plot/plot.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1741,9 +1741,14 @@ def b(n): return lambda x: bessel_J(n, x) + 0.5*(n-1)
17411741
17421742
::
17431743
1744-
sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
1744+
sage: plot(2*x + 1,(x, 0, 5), ticks=[[0, 1, e, pi, sqrt(20)], 2], tick_formatter="latex")
17451745
Graphics object consisting of 1 graphics primitive
17461746
1747+
.. PLOT::
1748+
1749+
g = plot(2*x + 1, (x, 0, 5), ticks=[[0, 1, e, pi, sqrt(20)], 2], tick_formatter="latex")
1750+
sphinx_plot(g)
1751+
17471752
This is particularly useful when setting custom ticks in multiples of `pi`.
17481753
17491754
::

0 commit comments

Comments
 (0)