ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 13 Jan 2016 05:12:58 -0600Tick labels in a matrix plothttps://ask.sagemath.org/question/32182/tick-labels-in-a-matrix-plot/I want to plot the following matrix `m` with k and l in {-2, ..., 2}:
m = [[k+l for k in range(-2,3)] for l in range(-2,3)]
with `matrix_plot`:
m_plot = matrix_plot(m, origin='lower')
The ticks on both axes are automatically set to {0 , ... , 5}, but I want the ticks to be {-2, -1, 0, 1, 2} on both axes.
I could not figure out how to do this.Wed, 13 Jan 2016 04:37:55 -0600https://ask.sagemath.org/question/32182/tick-labels-in-a-matrix-plot/Answer by vdelecroix for <p>I want to plot the following matrix <code>m</code> with k and l in {-2, ..., 2}:</p>
<pre><code>m = [[k+l for k in range(-2,3)] for l in range(-2,3)]
</code></pre>
<p>with <code>matrix_plot</code>:</p>
<pre><code>m_plot = matrix_plot(m, origin='lower')
</code></pre>
<p>The ticks on both axes are automatically set to {0 , ... , 5}, but I want the ticks to be {-2, -1, 0, 1, 2} on both axes.
I could not figure out how to do this.</p>
https://ask.sagemath.org/question/32182/tick-labels-in-a-matrix-plot/?answer=32184#post-id-32184Hello,
You could use the option **ticks** and **tick_formatter** as follows
sage: matrix_plot(m, ticks=[[0,1,2,3,4],[0,1,2,3,4]], tick_formatter=[[-2,-1,0,1,2],[-2,-1,0,1,2]])
These are documented in the function plot and you can access the help with
sage: plot?Wed, 13 Jan 2016 05:12:58 -0600https://ask.sagemath.org/question/32182/tick-labels-in-a-matrix-plot/?answer=32184#post-id-32184