Ask Your Question
1

Some questions on plot

asked 2023-03-23 00:10:44 +0200

Cyrille gravatar image

updated 2023-03-23 08:05:37 +0200

Emmanuel Charpentier gravatar image

This is a multi-form question. After this question https://ask.sagemath.org/question/67023/error-in-listing-a-zip/ my code works anew. Do not ask me why ?

But I encounter some new problems. I have had problem to make docker works properly on my computer. But now I would like to enlight the following code (look at 3) for the docker problem)

billes=[ZZ.random_element(0, 4) for i in range(50)]
billes+=[ZZ.random_element(5, 10) for i in range(80)]
billes+=[ZZ.random_element(10, 25) for i in range(21)]
billes+=[ZZ.random_element(25, 50) for i in range(28)]
billes+=[ZZ.random_element(50, 100) for i in range(28)]
shuffle(billes)#no necessary here only to confirm
billes1=sorted(billes)
binbilles1=[[x for x in billes1 if 0 <= x < 4],[x for x in billes1 if 5 <= x < 10],[x for x in billes1 if 10 <= x < 25],[x for x in billes1 if 25 <= x < 50],[x for x in billes1 if 50 <= x < 100]]
avbinbilles1=[len(x)^(-1)*sum(x) for x in binbilles1]
number=[len(x) for x in binbilles1]
cumsumpop=[sum(number[:i]) for i in range(1, len(number)+1)]
percumsumpop=[0]+[sum(number[:i])/sum(number) for i in range(1, len(number)+1)]
cumsumavbinbilles1=[sum(avbinbilles1[:i]) for i in range(1, len(avbinbilles1)+1)]
percumsumavbinbilles1=[0]+[sum(avbinbilles1[:i])/sum(avbinbilles1) for i in range(1, len(avbinbilles1)+1)]
#percumbilles1=[0]+[sum(binbilles1[:i])/sum(number) for i in range(1, len(binbilles1)+1)]
show(percumsumpop)
show(percumsumavbinbilles1)
A=zip(percumsumpop,percumsumavbinbilles1)
p=line([(0,1),(1,1),(1,0)],color='black')
p+=list_plot(list(A),color='red',plotjoined=true,aspect_ratio=1)
p+=line([(0,0),(1,1)])
p+=text(r"$Courbe\,\, de\,\, Lorenz$",(0.2,0.95), color='green')
p+=text(r"$Pourcentages\,\, Cumulés\,\, de \,\, la \,\, Population$",(-0.1,0.5), color='green', rotation=90)
p+=text(r"$Pourcentages\,\, Cumulés\,\, de \,\, la \,\, richesse$",(0.5,-0.1), color='green', rotation=0)
show(p)
  1. I would like to fill the space between the red and the blue line but I do not find how
  2. I would like to change the font of the ticks and label if I use them but I do not find how
  3. I use Docker but I do not know how to gives access to Latex (We need a container with bot Sagemath and latex)
  4. Incidently, I do notknow how to make docker remanent. Each time I shut down my computer , I loose all my notebooks
edit retag flag offensive close merge delete

Comments

Reformatted for legibility.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2023-03-23 08:06:04 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2023-03-23 08:28:36 +0200

Emmanuel Charpentier gravatar image

Very partial answer If you have four questions, ask four question !

  1. Try :

    p+polygon(list(zip(percumsumpop, percumsumavbinbilles1)), color="blue")

    and season to taste (color, opacity, etc...)

  2. see matplotlib options, and create such an object manually.

  3. Dunno...

  4. Dunno...

HTH,

edit flag offensive delete link more

Comments

Thanks Emmanuel, you can see that I try intensively to learn SageMath and Python (Smile)

Cyrille gravatar imageCyrille ( 2023-03-23 09:37:44 +0200 )edit

I must admit that this morning I posted a solution for the first question, but when i saw @Emmanuel Charpentier's solution, i was ashamed of my solution and quickly deleted it!. I don't know if you had time to see it. But I'm putting it back online for an example of clumsy SageMath coding. What not to do : 20 lines of very slow code against only one elegant and speedy Emmanuel line ;-). be patient you have to wait 30 secondes to see the plot !

clumsy solution Does anybody knows why my solution is taking so much time ?

edited:24/03/2023 it is the construction of the plot of the filling function (pp) between the line and the piecewise function which takes 35 seconds! time durations

ortollj gravatar imageortollj ( 2023-03-23 19:01:43 +0200 )edit

@Cyrille I don't know if you work with W11 but I report a problem with standby return with WSL W11. my advice is to avoid putting your PC on standby when WSL is running. Maybe there is a similar problem with Docker? W11 WSL return of sleep mode problem

ortollj gravatar imageortollj ( 2023-03-23 19:04:28 +0200 )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: 2023-03-23 00:10:44 +0200

Seen: 234 times

Last updated: Mar 23 '23