Ask Your Question
1

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

asked 4 years ago

PatB gravatar image

updated 4 years ago

slelievre gravatar image

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 4 years ago

slelievre gravatar image

updated 4 years ago

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()
Preview: (hide)
link

Comments

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!

PatB gravatar imagePatB ( 4 years ago )

If that answers your question, you can mark the answer as accepted, which will also marked your question as solved.

slelievre gravatar imageslelievre ( 4 years ago )

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.

slelievre gravatar imageslelievre ( 4 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 4 years ago

Seen: 217 times

Last updated: Dec 26 '20