Ask Your Question
0

Interaction with a graphics

asked 2019-09-25 02:18:01 -0600

Cyrille gravatar image

updated 2019-09-25 02:52:03 -0600

This code is very efficient.

> p1=plot(.3/x, (x, .38,
> 2),thickness=2,ticks=[[], []])
> p2=plot(.4/x, (x, .5, 2),thickness=1,
> linestyle="--") p3=plot(0.6-.305*x,
> (x, 0, 1.96),thickness=2,color='red')
> t1=text("$\overline{U}^1(x)$", (2,
> .3), fontsize=12, color="black")
> t2=text("$\overline{U}^\star(x)$", (2,
> .1), fontsize=12, color="black")
> t3=text("$x^\star$", (1, -.05),
> fontsize=12, color="black")
> t4=text("$y^\star$", (-0.05,.3),
> fontsize=12, color="black")
> t5=text("$R/p_x$", (2, -.05),
> fontsize=12, color="black")
> t6=text("$R/p_y$", (-0.075, .6),
> fontsize=12, color="black")
> c1=circle((1,.3), .015, fill=True,
> edgecolor='green', facecolor='green')
> l1=line(([1,0],[1,0.2975],[0,0.2975]),
> linestyle="--",color='red')
> g=p1+p2+p3+t1+t2+t3+t4+t5+t6+l1+c1
> g.axes_labels(['$x$','$y$'])
> g.set_legend_options(font_size=6) 
> g

up to the fact that I cannot use \frac {R}{p_x} in the plot.

It does exactly what I expect. I use the last version of sagemath on Windows. I want to interact it on the parameters $R$, $p_x$, $p_y$, to plot the contours $U$ and with the help of sliders change the curve until it become tangent to the line. I do not know why all my tentative to use interact with a less complex graphics fails. Need help. Thank you.

PS Need help does'nt signifie to do the work for me but to help me to start. I want to become expert in Sagemath

edit retag flag offensive close merge delete

Comments

You can use \frac{R}{x_p} in the plot: you simply need to enter it as a raw string, via the prefix 'r' in front of the quotes. This guarantees that the backslash of \frac is correctly interpreted as part of a LaTeX command:

t5 = text(r"$\frac{R}{p_x}$", (2, -.05), fontsize=12, color="black")

Equivalently, you can use a double backslash:

t5=text("$\\frac{R}{p_x}$", (2, -.05), fontsize=12, color="black")
eric_g gravatar imageeric_g ( 2019-09-25 06:38:56 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-09-25 03:37:33 -0600

Emmanuel Charpentier gravatar image

This feature (nowadays Jupyter notebook only, IIRC) is called interact in Sage. Armed with this bit of not-so-obvious knowledge, a simple Google would point you to this Quickstart page and this whole Wiki chapter.

The "hard metal" documentation is more easily understood after playing with a few examples...

edit flag offensive delete link more

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: 2019-09-25 02:18:01 -0600

Seen: 42 times

Last updated: Sep 25 '19