ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 05 Dec 2020 12:08:08 +0100How to show lines and images on a chess board (matrix_plot)https://ask.sagemath.org/question/54565/how-to-show-lines-and-images-on-a-chess-board-matrix_plot/Hi,
I naively created a chess board with a matrix_plot.
m = matrix_plot([[1,0,1,0,1,0,1,0],
[0,1,0,1,0,1,0,1],
[1,0,1,0,1,0,1,0],
[0,1,0,1,0,1,0,1],
[1,0,1,0,1,0,1,0],
[0,1,0,1,0,1,0,1],
[1,0,1,0,1,0,1,0],
[0,1,0,1,0,1,0,1],
[1,0,1,0,1,0,1,0]]
)
Shown alone, it looks almost like a chess board, but it has axes and white padding on the periphery
(m).show(aspect_ratio=1)
I then naively tried to add a line to that plot -
Q = line([(-0.5,0),(1,1)])
(m+Q).show()
Somehow I have lost the whole matrix plot . This is version 8.7 in a jupyter notebook
Q = line([(-0.5,0),(1,1)])
(m+Q).show()
i only get 2 rows - the rest is truncated.
Question - how to graph lines on top of this matrix plot without truncating the apprearance?
Merci!
PatSat, 05 Dec 2020 05:43:20 +0100https://ask.sagemath.org/question/54565/how-to-show-lines-and-images-on-a-chess-board-matrix_plot/Answer by slelievre for <p>Hi,
I naively created a chess board with a matrix_plot.</p>
<pre><code>m = matrix_plot([[1,0,1,0,1,0,1,0],
[0,1,0,1,0,1,0,1],
[1,0,1,0,1,0,1,0],
[0,1,0,1,0,1,0,1],
[1,0,1,0,1,0,1,0],
[0,1,0,1,0,1,0,1],
[1,0,1,0,1,0,1,0],
[0,1,0,1,0,1,0,1],
[1,0,1,0,1,0,1,0]]
)
</code></pre>
<p>Shown alone, it looks almost like a chess board, but it has axes and white padding on the periphery</p>
<pre><code> (m).show(aspect_ratio=1)
</code></pre>
<p>I then naively tried to add a line to that plot - </p>
<pre><code>Q = line([(-0.5,0),(1,1)])
(m+Q).show()
</code></pre>
<p>Somehow I have lost the whole matrix plot . This is version 8.7 in a jupyter notebook</p>
<pre><code>Q = line([(-0.5,0),(1,1)])
(m+Q).show()
</code></pre>
<p>i only get 2 rows - the rest is truncated.</p>
<p>Question - how to graph lines on top of this matrix plot without truncating the apprearance?</p>
<p>Merci!
Pat</p>
https://ask.sagemath.org/question/54565/how-to-show-lines-and-images-on-a-chess-board-matrix_plot/?answer=54569#post-id-54569This seems to work fine in recent Sage.
- with Jupyter on my local installation (Sage 9.3.beta2)
- on SageCell (main server currently at Sage 9.1; test server currently at Sage 9.2)
Illustration:
- [Matrix plot and a line on Sage Cell](https://sagecell.sagemath.org/?z=eJzlkj9PwzAQxXd_iid1sYVJYkEYKmVgYepSMUZVdaRubSWOU5_58_GxEEhA-QacdMu9373h3q1wzyMe6WRxfracfZzR3rZ37RobP1sGzQf4UHRGkQiDs8xPkdJBrOByXnhd18RjxYUJlF0V06n-8qo_vIRYkp-zfLGJy1AqJURAh4In_7Zfpphl3xvd6G-90wK_q_9BaPMn8198LiHixQ55n6icvjMX8jFRsN0DTWyVCBW7-CqV2JYgphK17OV1U7UajdKQRsOonUZ2fhjLH3B3o4QMuMJWfW6-A0jyf1Q=&lang=sage&interacts=eJyLjgUAARUAuQ==)
In your Jupyter, try clicking in the "left margin" of the output,
this might toggle between truncated view and full view.Sat, 05 Dec 2020 12:08:08 +0100https://ask.sagemath.org/question/54565/how-to-show-lines-and-images-on-a-chess-board-matrix_plot/?answer=54569#post-id-54569