{"id":1393,"date":"2023-04-21T16:07:54","date_gmt":"2023-04-21T15:07:54","guid":{"rendered":"https:\/\/blog.univ-angers.fr\/mathsinfo\/?p=1393"},"modified":"2023-04-22T12:25:16","modified_gmt":"2023-04-22T11:25:16","slug":"graphiques-en-secteurs-et-humour","status":"publish","type":"post","link":"https:\/\/blog.univ-angers.fr\/mathsinfo\/2023\/04\/21\/graphiques-en-secteurs-et-humour\/","title":{"rendered":"Graphiques en secteurs et humour"},"content":{"rendered":"\n<p>Il y a une dizaine d&rsquo;ann\u00e9es certains internautes se sont amus\u00e9s \u00e0 cr\u00e9er des graphiques en secteurs originaux, voyons comment les reproduire en Python avec la TI-83<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Le coin de ma chambre<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-47.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-47.png\" alt=\"\" class=\"wp-image-1397\" width=\"404\" height=\"313\" \/><\/a><figcaption class=\"wp-element-caption\">2 murs et le sol<\/figcaption><\/figure>\n<\/div>\n\n\n<pre class=\"wp-block-code\"><code>import ti_plotlib as plt\nfrom ti_draw import *\nfrom math import *\n\ndata = {-14: (143, 133, 133), 90: (158, 143, 133), 214: (93, 42, 40)}\n\ndef dec(l,n,u): return &#091;v&#091;n] + u for v in l]\n\ndef secteurs(data):\n  plt.cls()\n  o = (0, 0)\n  xy = &#091;o]\n  mini = min(data.keys())\n  for i in range(mini, 361 + mini):\n    xy.append((cos(radians(i)) * 100, -sin(radians(i)) * 100))\n    if i in data.keys():\n      if i != mini: fill_poly(dec(xy, 0, 160), dec(xy, 1, 105))\n      set_color(*data&#091;i])\n      xy = &#091;o] + xy&#091;-1:]\n  fill_poly(dec(xy, 0, 160), dec(xy, 1, 105))\n\nsecteurs(data)\nshow_draw()<\/code><\/pre>\n\n\n\n<p>Les donn\u00e9es sont repr\u00e9sent\u00e9es sous la forme <strong>angle : couleur<\/strong>. Pour l&rsquo;exemple ci-dessus, on part de l&rsquo;angle -14\u00b0 avec la couleur (143, 133, 133), on trace le secteur jusqu&rsquo;\u00e0 l&rsquo;angle 90\u00b0 puis on change de couleur, etc.<\/p>\n\n\n\n<p>L&rsquo;id\u00e9e du programme est de tracer un polygone en partant du centre de l&rsquo;\u00e9cran (160, 105), la variable <strong>i <\/strong>parcourt les entiers allant de l&rsquo;angle le plus petit (-14\u00b0 dans l&rsquo;exemple) jusqu&rsquo;\u00e0 faire un tour complet (360 &#8211; 14 = 346\u00b0). On m\u00e9morise dans la variable <strong>xy<\/strong> les coordonn\u00e9es des points sur le bord du cercle de 1\u00b0 en 1\u00b0 et d\u00e8s qu&rsquo;il y a un changement de couleur on trace le polygone <strong>xy<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">La pyramide<\/h3>\n\n\n\n<p>M\u00eame programme que pr\u00e9c\u00e9demment mais en changeant <strong>data<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-48.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-48.png\" alt=\"\" class=\"wp-image-1398\" width=\"376\" height=\"286\" \/><\/a><figcaption class=\"wp-element-caption\">Une pyramide ?<\/figcaption><\/figure>\n<\/div>\n\n\n<pre class=\"wp-block-code\"><code>data = {-42: (65, 100, 145), 222: (210, 163, 83), 298: (88, 57, 36)}<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-52.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-52.png\" alt=\"\" class=\"wp-image-1410\" width=\"338\" height=\"259\" \/><\/a><figcaption class=\"wp-element-caption\">Version Ma\u00eetre Gims<\/figcaption><\/figure>\n<\/div>\n\n\n<pre class=\"wp-block-code\"><code>data = {-42: (65, 100, 145), -1: (220,220,220), 0:(65, 100, 145), \\\n        179: (220,220,220), 180:(65, 100, 145), 202: (220,220,220), \\\n        204:(65, 100, 145), 222: (210, 163, 83), 298: (88, 57, 36)}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">pacman<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-49.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-49.png\" alt=\"\" class=\"wp-image-1399\" width=\"372\" height=\"283\" srcset=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-49.png 461w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-49-300x227.png 300w, https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-49-396x300.png 396w\" sizes=\"auto, (max-width: 372px) 100vw, 372px\" \/><\/a><figcaption class=\"wp-element-caption\">PACMAN<\/figcaption><\/figure>\n<\/div>\n\n\n<pre class=\"wp-block-code\"><code>data = {-32: (255, 255, 255), 32: (216, 160, 24)}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">D\u00e9grad\u00e9<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-50.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/files\/2023\/04\/image-50.png\" alt=\"\" class=\"wp-image-1406\" width=\"347\" height=\"264\" \/><\/a><\/figure>\n<\/div>\n\n\n<pre class=\"wp-block-code\"><code>data = {}\n\nfor i in range(20): data&#091;18 * i] = (12 * i,) * 3<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Il y a une dizaine d&rsquo;ann\u00e9es certains internautes se sont amus\u00e9s \u00e0 cr\u00e9er des graphiques en secteurs originaux, voyons comment les reproduire en Python avec la TI-83 Le coin de ma chambre Les donn\u00e9es sont repr\u00e9sent\u00e9es sous la forme angle &hellip; <a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/2023\/04\/21\/graphiques-en-secteurs-et-humour\/\">Continuer la lecture <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":4913,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1393","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/users\/4913"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/comments?post=1393"}],"version-history":[{"count":8,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1393\/revisions"}],"predecessor-version":[{"id":1411,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1393\/revisions\/1411"}],"wp:attachment":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/media?parent=1393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/categories?post=1393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/tags?post=1393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}