Skip to content

Commit

Permalink
Finir de régler le problème plotly (#236)
Browse files Browse the repository at this point in the history
* 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] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
linogaliana and github-actions[bot] committed Jun 10, 2022
1 parent ef57cd3 commit 640b960
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
14 changes: 7 additions & 7 deletions build/tweak_markdown.py
Expand Up @@ -16,7 +16,7 @@ def replace_shortcode_tabs(content):

def tweak_js_plotly(content):
content2 = re.sub(
r'<script type="text/javascript">\n([\S\s]*)</script>\n',
r'<script type="text/javascript">\n\s*window([\S\s]*)</script>\n',
'',
content)
return content2
Expand All @@ -32,16 +32,16 @@ def clean_write_file(fl):
add_text = '\n\n<script src="https://d3js.org/d3.v7.min.js"></script>\n<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>'
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'<script type="text/javascript">\n([\S\s]*)</script>\n',
# content) is not None:
# print("plotly detected")
# content = tweak_js_plotly(content)
if re.search(
r'<script type="text/javascript">\n\s*window.P([\S\s]*)</script>\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)
Expand Down
25 changes: 10 additions & 15 deletions content/course/modelisation/0_preprocessing/index.qmd
Expand Up @@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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" >}}



Expand Down

0 comments on commit 640b960

Please sign in to comment.