Enhancing a plot

asked 2021-06-21 17:26:15 +0100

Cyrille gravatar image

updated 2021-06-22 16:46:20 +0100

Consider the following code.

f0(x)=3-x
f1(x)=2*x-6
f2(x)=1+(1/3)*x
p=plot(f0(x),x,1,3.5,thickness=3)
p+=plot(f1(x),x,2.7,4.5,thickness=3)
p+=plot(f2(x),x,1,4.5,thickness=3)
sol0=solve(f0==f1,x)
sol1=solve(f0==f2,x)
sol2=solve(f1==f2,x)
p+=point((sol0[0].rhs(),f1(sol0[0].rhs())), rgbcolor=(0.26, 0.80, 0.50),size=60, zorder=10,axes_labels=['$x_1$','$x_2$'])
p+=point((sol1[0].rhs(),f2(sol1[0].rhs())), rgbcolor=(0.26, 0.80, 0.50),size=60, zorder=10)
p+=point((sol2[0].rhs(),f1(sol2[0].rhs())), rgbcolor=(0.26, 0.80, 0.50),size=60, zorder=10)
p+=point((0,f2(sol2[0].rhs())), rgbcolor=(0.99, 0.86, 0.23),size=60, zorder=10)

p+=point((0,0), rgbcolor=(0.99, 0.86, 0.23),size=60, zorder=10)
p+=line([(0,0),(0,f2(sol2[0].rhs()))],rgbcolor=(.5, 0.5, 0.69),thickness=3, zorder=8)
p+=point((sol1[0].rhs(),0), rgbcolor=(1, 0.1, 0.5),size=60, zorder=10)
p+=point((sol2[0].rhs(),0), rgbcolor=(1, 0.1, 0.5),size=60, zorder=10)
p+=line([(sol1[0].rhs(),0),(sol2[0].rhs(),0)],rgbcolor=(1, 0.5, 0.69),thickness=3, zorder=8)
p+=polygon([(sol0[0].rhs(),f1(sol0[0].rhs())),(sol1[0].rhs(),f2(sol1[0].rhs())),(sol2[0].rhs(),f1(sol2[0].rhs()))], rgbcolor=(0.9098, 0.3804, 0))
p+=text("$\\mathrm{Points }\\,\\, \\mathrm{intérieurs}$",(2.8,1.2), color='white')
p+=text("$x_2=3-x_1$",(1.9,.6),rotation=-44.0, horizontal_alignment='left')
p+=text("$x_2=2x_1-6$",(3.5,1.2),rotation=62.0, horizontal_alignment='left')
p+=text("$0$",(-.15,0.1), horizontal_alignment='center',color='black',fontsize=12)
p+=text("$x_2=1+(1/3)x_1$",(3,2.2),rotation=16.0, horizontal_alignment='center')
p+=line([(sol1[0].rhs(),0),(sol1[0].rhs(),f2(sol1[0].rhs()))],linestyle="--",color='black')
p+=line([(sol2[0].rhs(),0),(sol2[0].rhs(),f2(sol2[0].rhs())), (0,f2(sol2[0].rhs()))],linestyle="--",color='black')
p+=line([(0,0), (sol1[0].rhs(),0)],linestyle="--",color='black')
show(p,aspect_ratio=1,axes=[False, False])#,transparent=True)

In the resulting plot, I would like to replace the portion of the horizontal axis between the yellow dot and the red dot by a horizontal dashed line. Is it possible?

Another question is how to display the values of the points on the axes.

Also, it seems there is no possibility to fill a polygon with a transparent color.

Another question: how to have the ticks in computer modern because two fonts is not nice.

And last but not least, I have seen that opacity is normally obtained by different words as opacity or alpha according to the context.

edit retag flag offensive close merge delete

Comments

Hi Cyrille

you must not start your message with code, but with an explanatory text otherwise the code will not be formatted. ( this problem has already happened to me !)

ortollj gravatar imageortollj ( 2021-06-22 07:30:49 +0100 )edit

Ok I will do like that.

Cyrille gravatar imageCyrille ( 2021-06-22 16:46:49 +0100 )edit