Skip to content

Commit

Permalink
quelques mots sur vizu
Browse files Browse the repository at this point in the history
  • Loading branch information
linogaliana committed Sep 24, 2020
1 parent 66f9f87 commit 94f39ec
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
26 changes: 26 additions & 0 deletions content/visualisation/matplotlib/TP/index.Rmd
@@ -0,0 +1,26 @@
---
jupyter:
jupytext:
text_representation:
extension: .Rmd
format_name: rmarkdown
format_version: '1.2'
jupytext_version: 1.6.0
kernelspec:
display_name: Python 3
language: python
name: python3
title: "De beaux graphiques avec python: mise en pratique"
date: 2020-09-24T13:00:00Z
draft: false
weight: 10
output:
html_document:
keep_md: true
self_contained: true
slug: matplotlib
---

La pratique de la visualisation se fera, dans ce cours, en répliquant des graphiques qu'on peut trouver sur
la page de l'*open-data* de la ville de Paris
[ici](https://opendata.paris.fr/explore/dataset/comptage-velo-donnees-compteurs/information/?disjunctive.id_compteur&disjunctive.nom_compteur&disjunctive.id&disjunctive.name)
74 changes: 74 additions & 0 deletions content/visualisation/matplotlib/tutorial/index.Rmd
@@ -0,0 +1,74 @@
---
jupyter:
jupytext:
text_representation:
extension: .Rmd
format_name: rmarkdown
format_version: '1.2'
jupytext_version: 1.6.0
kernelspec:
display_name: Python 3
language: python
name: python3
title: "matplotlib: la brique de base des graphiques python"
date: 2020-09-24T13:00:00Z
draft: false
weight: 10
output:
html_document:
keep_md: true
self_contained: true
slug: matplotlib
---

https://pandas.pydata.org/pandas-docs/stable/user_guide/visualization.html
https://pandas.pydata.org/pandas-docs/stable/user_guide/visualization.html#plot-formatting


Newer tools like ggplot and ggvis in the R language, along with web visualization toolkits based on D3js and HTML5 canvas, often make Matplotlib feel clunky and old-fashioned. Still, I'm of the opinion that we cannot ignore Matplotlib's strength as a well-tested, cross-platform graphics engine. Recent Matplotlib versions make it relatively easy to set new global plotting styles (see Customizing Matplotlib: Configurations and Style Sheets), and people have been developing new packages that build on its powerful internals to drive Matplotlib via cleaner, more modern APIs—for example, Seaborn (discussed in Visualization With Seaborn), ggpy, HoloViews, Altair, and even Pandas itself can be used as wrappers around Matplotlib's API

La structure sous-jacente de matplotlib est très générale et personnalisable (gestion de l’interface utilisateur, possibilité d’intégration dans des applications web, etc.). Heureusement, il n’est pas nécessaire de maîtriser l’ensemble de ces méthodes pour produire un graphe (il existe pas moins de 2840 pages de documentation). Pour générer des graphes et les modifier, il suffit de passer par l’interface `pyplo

## Comment appeler `matplotlib` ?


show() or No show()? How to Display Your Plots

A visualization you can't see won't be of much use, but just how you view your Matplotlib plots depends on the context. The best use of Matplotlib differs depending on how you are using it; roughly, the three applicable contexts are using Matplotlib in a script, in an IPython terminal, or in an IPython notebook.
Plotting from a script

If you are using Matplotlib from within a script, the function plt.show() is your friend. plt.show() starts an event loop, looks for all currently active figure objects, and opens one or more interactive windows that display your figure or figures.

So, for example, you may have a file called myplot.py containing the following:

# ------- file: myplot.py ------
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)

plt.plot(x, np.sin(x))
plt.plot(x, np.cos(x))

plt.show()

You can then run this script from the command-line prompt, which will result in a window opening with your figure displayed:

$ python myplot.py

The plt.show() command does a lot under the hood, as it must interact with your system's interactive graphical backend. The details of this operation can vary greatly from system to system and even installation to installation, but matplotlib does its best to hide all these details from you.


NB: %matplotlib inline


Sauver un graphe: Saving a figure can be done using the savefig() command.


A potentially confusing feature of Matplotlib is its dual interfaces: a convenient MATLAB-style state-based interface, and a more powerful object-oriented interface. We'll quickly highlight the differences between the two here.

* MATLAB-style Interface
* Object-oriented interface


**LIEN TP: premier graphique en matplotlib --> modifier les axes**

0 comments on commit 94f39ec

Please sign in to comment.