First time here? Check out the FAQ!

Ask Your Question
1

Incorrect graph structure

asked 6 years ago

Sha gravatar image

Hi. I have done some research on how to build my graph based on the info i obtained from http://doc.sagemath.org/html/en/refer...

Here is what I have done :

h=plot(x, (x,-73.83,73.83),linestyle="--")
g=plot(-0.7350*x+67, (x,-73.83,73.83),linestyle="--")
r=list_plot([(11.13,58.82),(4.99,10.03),(17.24,42.79),(23.80,-73.83),(57.84,-37.82)], axes_labels=['(+) GE','(+) CE']))
r += text('A CMSCI = 0.131', (11.135, 58.82))
H = h + g + r;H
print(H)

which gave me this below:

image description

It looks almost the same as how i want it to be which is (at least the lines and the points are there (haha)):

image description

Few questions here:

  1. how to scale the axis properly. my y-axis is wider than x-axis
  2. how to form the outer box and add P, Q, R, S labels
  3. i manage to form the axis title only for (+)GE and (+)CE, how about the (-) ones?

Thank you.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 6 years ago

slelievre gravatar image

updated 6 years ago

Getting the same scale for the x and y axes is achieved using aspect_ratio.

Getting an outer box is achieved using frame. The ticks will be on the box though.

Not sure how to get the labels on the min side of the axes...

The following is maybe already a step closer to your desired output.

h = plot(x, (x, -73.83, 73.83), linestyle="--")
g = plot(-0.7350*x + 67, (x, -73.83, 73.83), linestyle="--")
p = [(11.13, 58.82), (4.99, 10.03), (17.24, 42.79), (23.80, -73.83), (57.84, -37.82)]
r = list_plot(p, axes_labels=['(+) GE', '(+) CE'])
r += text('A CMSCI = 0.131', (11.135, 58.82))
H = h + g + r
H.show(aspect_ratio=1, frame=True, ymin= -73.83, ymax=73.83)

See the possible options to show in the documentation, either by typing H.show? after defining H as above, or online at:

Preview: (hide)
link

Comments

Thank you for the reply. Just a quick question: How to fix the y-axis range? I manage to fix the range for x-axis by using: , (x,-73.83,73.83), but couldn't do so for y-axis. The reason here is because I need a square box.

Sha gravatar imageSha ( 6 years ago )

I found this in the documentation you gave :

L = line([(1,2), (3,-4), (2, 5), (1,2)])

L.set_axes_range(-1, 20, 0, 2)

Tried it but it did not quite worked. It said:

AttributeError: 'list' object has no attribute 'set_axes_range'

Sha gravatar imageSha ( 6 years ago )
1

I edited the answer, adding ymin=..., ymax=....

slelievre gravatar imageslelievre ( 6 years ago )

thank you for your help. This gave me the graph i want. thanks.

Sha gravatar imageSha ( 6 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: 6 years ago

Seen: 762 times

Last updated: Jul 31 '18