From 640b96057252244774a4c4dbd5482063da6a8af0 Mon Sep 17 00:00:00 2001 From: Lino Galiana <33896139+linogaliana@users.noreply.github.com> Date: Fri, 10 Jun 2022 15:42:04 +0200 Subject: [PATCH] =?UTF-8?q?Finir=20de=20r=C3=A9gler=20le=20probl=C3=A8me?= =?UTF-8?q?=20plotly=20(#236)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * do not show * Automated changes * Automated changes * more specific regex * Automated changes * Automated changes * modifs de forme * Automated changes * Automated changes Co-authored-by: github-actions[bot] --- build/tweak_markdown.py | 14 +++++------ .../modelisation/0_preprocessing/index.qmd | 25 ++++++++----------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/build/tweak_markdown.py b/build/tweak_markdown.py index 2deb04d2f..7cbb41694 100644 --- a/build/tweak_markdown.py +++ b/build/tweak_markdown.py @@ -16,7 +16,7 @@ def replace_shortcode_tabs(content): def tweak_js_plotly(content): content2 = re.sub( - r'\n', + r'\n', '', content) return content2 @@ -32,16 +32,16 @@ def clean_write_file(fl): add_text = '\n\n\n' yaml, text = content.split('---\n', 2)[1:] if re.search("plotly: true", yaml) is not None: - print(f"Tweaking {fl}") + print(f"Tweaking {fl} using YAML header") content = "---\n"+ yaml + "---\n" \ + add_text+"\n"+text else: print(f"File {fl}: nothing to do") -# if re.search( -# r'\n', -# content) is not None: -# print("plotly detected") -# content = tweak_js_plotly(content) + if re.search( + r'\n', + content) is not None: + print("quarto added plotly detected: removed") + content = tweak_js_plotly(content) write_file(fl, content) list_files = glob.glob("./content/course/**/index.md", recursive=True) diff --git a/content/course/modelisation/0_preprocessing/index.qmd b/content/course/modelisation/0_preprocessing/index.qmd index b95fd6ff9..4bfafe2b9 100644 --- a/content/course/modelisation/0_preprocessing/index.qmd +++ b/content/course/modelisation/0_preprocessing/index.qmd @@ -3,7 +3,6 @@ title: "Préparation des données pour construire un modèle" date: 2020-10-15T13:00:00Z draft: false weight: 10 -plotly: true output: html_document: keep_md: true @@ -24,6 +23,7 @@ summary: | dépend fortement de ce travail préalable de preprocessing. Beaucoup de méthodes sont disponibles dans scikit, ce qui rend ce travail moins fastidieux. +plotly: true --- ```{python} @@ -138,10 +138,6 @@ plt.axis('off') # plt.show() ``` -```{python} -ax.get_figure() -``` - Les cartes choroplèthes peuvent donner une impression fallacieuse ayant servi de justification pour contester les résultats du vote. En effet, un biais @@ -213,16 +209,12 @@ fig_plotly.update_layout( geo = {"scope": 'usa', "landcolor": 'rgb(217, 217, 217)'} ) -fig_plotly.show() -``` - - -```{python} -#| include: false +# Pour inclusion sur site web fig_plotly.write_json("people_vote.json") ``` - +Les cercles proportionnels permettent ainsi à l'oeil de se concentrer sur les +zones les plus denses et non sur les grands espaces. ## Explorer la structure des données @@ -304,20 +296,23 @@ ax ```{python scatter_matrix_plotly} #| include: false #| echo: false +#| output: hide # 4. Matrice de corélation avec plotly import plotly import plotly.express as px htmlsnip2 = px.scatter_matrix(df2) htmlsnip2.update_traces(diagonal_visible=False) -# Pour inclusion dans le site web -htmlsnip2.write_json("scatter_matrix.json") +# Pour inclusion dans le site web +htmlsnip2.write_json("scatter.json") ``` {{% /box %}} -{{< chart data="scatter_matrix" >}} +La matrice de corrélation devrait avoir l'aspect suivant: + +{{< chart data="scatter" >}}