Ask Your Question
1

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

asked 2020-12-25 21:31:32 +0100

PatB gravatar image

updated 2020-12-26 01:34:44 +0100

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?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2020-12-26 02:07:49 +0100

slelievre gravatar image

updated 2020-12-26 12:26:21 +0100

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()
edit flag offensive delete link more

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 ( 2020-12-26 05:24:45 +0100 )edit

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

slelievre gravatar imageslelievre ( 2020-12-26 07:07:04 +0100 )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.

slelievre gravatar imageslelievre ( 2020-12-26 07:10:19 +0100 )edit

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: 2020-12-25 21:31:32 +0100

Seen: 201 times

Last updated: Dec 26 '20