# Combined 2d plot: how to change the size of the object?

I have created a matrix plot and a line and combined them as follows:

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]],
aspect_ratio=1,
frame=False)
Q = line([(-0.5, 0), (1, 1)], thickness=3)


Combined graphics is (m+Q).

I would like to change the size of (m+Q), but (m+Q).set_axes_range() does not affect the values.

Here is an example showing no change when using set_axes_range():

What method should I use?

edit retag close merge delete

Sort by » oldest newest most voted

You need to give m + Q a new name.

Otherwise when you do (m + Q).set_axes_range(...) that gets applied to an object which you can no longer recover.

And when you later do (m + Q).get_axes_range(...) you are computing m + Q again and that cannot know about the operation you did on the lost object.

Try this:

sage: mQ = m + Q
sage: mQ.set_axes_range(xmin=-0.2, xmax=5.5, ymin=-0.5, ymax=1)
sage: print(mQ.get_axes_range())
sage: mQ.show()

more

Yes, that makes perfect sense!

I need to create a reference to this combined object - as you suggested mQ = m+Q allows me to do mQ.set_axes_range(...)

Merci Beaucoup! Une réponse le jour même de Noël!

( 2020-12-26 05:24:45 +0200 )edit

( 2020-12-26 07:07:04 +0200 )edit

From your profile page you can visit all your past questions and accept the answers that solve these questions to mark the questions as solved. This is done by clicking the "✓" below the "upvote" and "downvote" buttons and the answer's score.

( 2020-12-26 07:10:19 +0200 )edit